:root {
  --bg: #f4efe6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --line-2: #eef0f3;
  --brand: #0e746d;
  --brand-dark: #084f49;
  --blue: #405bb7;
  --danger: #c94c43;
  --ok: #23845d;
  --warn: #a5641b;
  --accent: #d9792b;
  --gold: #efb955;
  --side: #f8fafc;
  --side-2: #eef2f7;
  --rail-bg: #0f172a;
  --rail-fg: #cbd5e1;
  --rail-active: #14b870;
  --rail-hover: #1e293b;
}

* { box-sizing: border-box; }
*:before, *:after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

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

img { max-width: 100%; display: block; }

.app-html { overflow: hidden; }
.app-html body { overflow: hidden; }

/* ============================================================
   APP SHELL - 4-COLUMN LAYOUT
   ============================================================ */

.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid !important;
  grid-template-columns: 64px 220px minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  grid-template-areas: "rail filter content" !important;
  background: var(--bg);
  overflow: hidden;
  min-height: 0;
}

/* ---------- Icon Rail (64px dark menu) ---------- */
.icon-rail {
  grid-area: rail !important;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  background: var(--rail-bg) !important;
  color: var(--rail-fg);
  border-right: 1px solid #1e293b;
  overflow: hidden;
  min-height: 0;
  z-index: 10;
}

.rail-brand {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--rail-active), #0a8a55);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 10px;
  box-shadow: 0 4px 12px rgba(20, 184, 112, 0.3);
}
.rail-brand:hover { text-decoration: none; }

.rail-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--rail-fg);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
  padding: 0;
}
.rail-btn:hover {
  background: var(--rail-hover);
  color: #fff;
}
.rail-btn.active {
  background: var(--rail-active) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(20, 184, 112, 0.35);
}
.rail-btn.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--rail-active);
  border-radius: 0 2px 2px 0;
}
.rail-btn svg { width: 20px; height: 20px; display: block; }
.rail-btn.is-hidden { display: none !important; }
.rail-spacer { flex: 1 1 auto; min-height: 8px; }
.rail-profile {
  background: var(--rail-hover);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.rail-profile:hover { background: var(--rail-active); }

/* ---------- Topbar (hidden) ---------- */
.topbar { display: none !important; }

.topbar-left { min-width: 0; overflow: hidden; }
.topbar-title { min-width: 0; }
.topbar-title h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
  display: flex;
  gap: 8px;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-search {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  min-width: 240px;
  height: 36px;
  color: var(--muted);
  transition: all 0.15s ease;
}
.topbar-search svg { width: 16px; height: 16px; }
.topbar-search input {
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 13px;
  color: var(--ink);
  width: 100%;
  min-width: 0;
}
.topbar-search:focus-within {
  border-color: var(--rail-active);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 184, 112, 0.12);
}
.topbar-lang {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.topbar-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.topbar-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.topbar-btn svg { width: 16px; height: 16px; }
.topbar-logout-form { display: inline-flex; margin: 0; }
.topbar-logout { color: var(--danger); }
.topbar-logout:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

/* ---------- Filter Column (account list) ---------- */
.filter-column {
  grid-area: filter !important;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: var(--surface) !important;
  border-right: 1px solid var(--line);
  padding: 12px;
  display: flex !important;
  flex-direction: column;
  gap: 10px;
  overflow: hidden !important;
}
/* Only show the account filter column on the Chat view */
body:not([data-view="chat"]) .filter-column { display: none !important; }
body:not([data-view="chat"]) .app-shell {
  grid-template-columns: 64px minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  grid-template-areas: "rail content" !important;
}
.filter-section { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.filter-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.filter-count {
  font-size: 11px;
  background: var(--side-2);
  color: var(--muted);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
#accounts {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

/* ---------- Account chips ---------- */
.account-list { display: flex; flex-direction: column; gap: 4px; overflow: visible !important; }
.account-chip {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 12px;
  line-height: 1.3;
}
.account-chip:hover { border-color: #94a3b8; background: var(--surface-2); }
.account-chip.active {
  border-color: var(--rail-active);
  background: rgba(20, 184, 112, 0.08);
  color: var(--ink);
}
.account-chip strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.state-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #94a3b8;
  flex-shrink: 0;
}
.state-dot.logged_in, .state-dot.connected, .state-dot.online { background: var(--ok); }
.state-dot.pending { background: var(--warn); }
.state-dot.disconnected { background: #cbd5e1; }
.state-dot.all { background: linear-gradient(135deg, var(--ok) 50%, #cbd5e1 50%); }

/* ---------- Account List (v31 - expanded by default) ---------- */
.account-list-expanded {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}
.account-list-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.account-list-search:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}
.account-list-search input {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: var(--ink);
  min-width: 0;
  padding: 2px 0;
}
.account-list-search input::placeholder { color: var(--muted); }
.account-list-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.account-list-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  color: var(--ink);
}
.account-list-item:hover { background: var(--surface-2); }
.account-list-item.active {
  background: rgba(20, 184, 112, 0.10);
}
.account-list-item.active strong { color: var(--rail-active); }
.account-list-item-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.account-list-item-text strong {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.account-list-item-text small {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

/* ---------- Account Dropdown (v29b - legacy, kept for reference) ---------- */
.account-dropdown {
  position: relative;
  width: 100%;
}
.account-dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.account-dropdown-trigger:hover {
  border-color: #94a3b8;
  background: var(--surface-2);
}
.account-dropdown-trigger.is-open {
  border-color: var(--rail-active);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(20, 184, 112, 0.08);
}
.account-trigger-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.account-trigger-label {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.account-trigger-label strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.account-trigger-label small {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.account-trigger-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.account-counter {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}
.account-trigger-caret {
  color: var(--muted);
  transition: transform 0.18s;
}
.account-dropdown-trigger.is-open .account-trigger-caret {
  transform: rotate(180deg);
}

.account-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  max-height: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.account-dropdown-panel[hidden] { display: none !important; }

.account-dropdown-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-2);
}
.account-dropdown-search input {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: var(--ink);
  min-width: 0;
}
.account-dropdown-search input::placeholder { color: var(--muted); }

.account-dropdown-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-option {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 7px 8px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.account-option:hover { background: var(--surface-2); }
.account-option.active {
  background: rgba(20, 184, 112, 0.10);
}
.account-option.active strong { color: var(--rail-active); }
.account-option-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.account-option-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.account-option-text strong {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.account-option-text small {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.account-dropdown-empty {
  padding: 16px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Content Area (main) ---------- */
.content-area {
  grid-area: content !important;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.content-area > .view {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.content-area > .view.active {
  display: flex !important;
  flex-direction: column;
}
.content-area > .view.active > * { flex: 1 1 auto; min-height: 0; }

/* ---------- View containers ---------- */
.view { display: none; }
.view.active { display: flex; flex-direction: column; }

.page-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============================================================
   CHAT VIEW
   ============================================================ */
.chat-page {
  display: grid !important;
  grid-template-columns: 340px minmax(0, 1fr) !important;
  height: 100%;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}

.list-column {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.list-head h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.list-head-actions { display: flex; gap: 4px; }
.list-icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}
.list-icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.list-icon-btn svg { width: 16px; height: 16px; }

.filter-pills {
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding-bottom: 8px;
}
.filter-chip {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.filter-chip:hover { background: var(--surface-2); color: var(--ink); }
.filter-chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.chat-list-select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.chat-list-select select {
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 6px;
  font-size: 11px;
  background: var(--surface);
}

.list-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.list-select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
}

.conversation-list {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  background: var(--surface);
}

.conversation {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-2);
  transition: background 0.12s, transform 0.12s;
  margin: 0;
  border-radius: 0;
  min-height: 68px;
  position: relative;
}
.conversation::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.12s;
}
.conversation:hover { background: var(--surface-2); }
.conversation:hover::before { background: var(--line-2); }
.conversation.active {
  background: linear-gradient(90deg, rgba(20, 184, 112, 0.12), rgba(20, 184, 112, 0.04));
}
.conversation.active::before { background: var(--rail-active); }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, #94a3b8, #64748b);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.avatar-single, .avatar-inbound { background: linear-gradient(135deg, #14b870, #0a8a55); }
.avatar-group { background: linear-gradient(135deg, #405bb7, #2d3f80); }
.avatar-status { background: linear-gradient(135deg, #d9792b, #a5641b); }
.avatar-outbound { background: linear-gradient(135deg, #6366f1, #4f46e5); }

.conversation-copy { min-width: 0; overflow: hidden; }
.conversation-copy strong {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.conversation-copy small {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conversation-copy p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}
.kind-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(20, 184, 112, 0.08);
  color: var(--rail-active);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.conversation-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.conversation-meta time {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.conversation.active .conversation-meta time {
  color: var(--rail-active);
  font-weight: 600;
}
.conversation-meta b {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--rail-active);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(20, 184, 112, 0.35);
}
.custom-name-tag {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 2px;
}

.empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Chat column ---------- */
.chat-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg);
  overflow: hidden;
}

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.thread-info { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.thread-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.thread-avatar .thread-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thread-avatar .thread-avatar-text { position: relative; z-index: 1; }
.thread-meta { min-width: 0; flex: 1; }
.thread-meta h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #94a3b8;
  flex-shrink: 0;
}
.status-dot.state-online { background: var(--ok); }
.status-dot.state-offline { background: #cbd5e1; }
.status-dot.state-pending { background: var(--warn); }

.thread-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.thread-select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
  max-width: 140px;
}
.thread-icon-btn {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.thread-icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.thread-icon-btn svg { width: 14px; height: 14px; }

/* ---------- Messages ---------- */
.messages {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  background:
    radial-gradient(circle at 16px 16px, rgba(0,0,0,.03) 1px, transparent 1px),
    var(--bg);
  background-size: 24px 24px, auto;
}

.blank {
  margin: auto 0;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  display: flex;
  flex: 1 1 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 100%;
  align-self: stretch;
}
.blank-illu {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border-radius: 50%;
  color: var(--muted);
}
.blank-illu svg { width: 32px; height: 32px; }
.blank strong { display: block; font-size: 14px; color: var(--ink); }
.blank p { margin: 0; font-size: 12px; color: var(--muted); max-width: 280px; }

.message-loading {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  min-height: 100%;
  color: var(--muted);
  font-size: 13px;
}
.message-loading span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.message-loading span:nth-child(2) { animation-delay: 0.15s; }
.message-loading span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.message-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 78%;
  flex-shrink: 0;
}
.message-row.inbound { align-self: flex-start; }
.message-row.outbound { align-self: flex-end; flex-direction: row-reverse; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(135deg, #94a3b8, #64748b);
  flex-shrink: 0;
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
}
.message-avatar.avatar-inbound { background: linear-gradient(135deg, #14b870, #0a8a55); }
.message-avatar.avatar-outbound,
.message-avatar.avatar-operator { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.message-avatar.avatar-group { background: linear-gradient(135deg, #405bb7, #2d3f80); }
.message-avatar .message-avatar-img,
.message-avatar .avatar-img,
.thread-avatar .thread-avatar-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.message-avatar-img,
.avatar-img,
.thread-avatar-img { display: block; opacity: 0; transition: opacity .15s ease; }
.avatar-img.is-loaded,
.message-avatar-img.is-loaded,
.thread-avatar-img.is-loaded { opacity: 1; }
.avatar {
  position: relative;
  overflow: hidden;
}
.avatar .avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar .avatar-text { position: relative; z-index: 1; }

.message {
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 16px;
  border-top-left-radius: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  min-width: 60px;
  max-width: 100%;
  word-break: break-word;
}
.message.outbound {
  background: linear-gradient(135deg, #14b870, #0a8a55);
  color: #fff;
  border-top-left-radius: 16px;
  border-top-right-radius: 4px;
}
.message-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 500;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.message-sender { font-weight: 600; }
.message-meta-sep { opacity: 0.6; }
.message.outbound .message-meta { color: rgba(255,255,255,0.85); }
.message.outbound .message-sender { color: #fff; }
.message-body { white-space: pre-wrap; }
.message .media { max-width: 240px; border-radius: 8px; margin-top: 4px; }
.message .media-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--brand);
  font-size: 12px;
  text-decoration: underline;
}
.message.outbound .media-link { color: #fff; }
.messages-refreshing {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  margin: 8px 0;
}

/* ---------- Composer ---------- */
.composer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 20;
}
.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.paste-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  max-width: 320px;
  position: relative;
}
.paste-preview-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--side-2);
}
.paste-preview-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}
.paste-preview-icon { font-size: 16px; line-height: 1; }
.paste-preview-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.paste-preview-size { font-size: 10px; color: var(--muted); }
.paste-preview-remove {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 18px;
  height: 18px;
  border: 0;
  background: var(--side-2);
  border-radius: 50%;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.paste-preview-remove:hover { background: #fee; color: #c33; }

.composer-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
/* v42: Switched from CSS Grid to Flexbox.
   Grid was fragile with mixed-height items (32px buttons vs growing textarea).
   Flexbox gives predictable layout: fixed-size buttons + flex-grow textarea. */
.composer-input {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 5px 8px;
  transition: all 0.15s;
}
/* v45: buttons pinned to right side of input */
.composer-input-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.composer-input:focus-within {
  border-color: var(--rail-active);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 184, 112, 0.12);
}

/* v42: Template dropdown inside .composer-input must never affect flex layout */
.composer-input > .composer-template-dropdown {
  display: none;
}
.composer-input > .composer-template-dropdown:not([hidden]) {
  display: block;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 6px;
}
/* v38: Translate (language) button now lives INSIDE the input area, anchored to the left.
   Clicking only opens the dropdown; when collapsed the button just shows the active label. */
.composer-send-lang-wrap { position: relative; z-index: 60; flex-shrink: 0; }
.composer-send-lang-inline { display: inline-flex; align-items: center; }
.composer-send-lang-inline .composer-lang-btn {
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  gap: 4px;
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
  flex-shrink: 0;            /* v42: prevent button from shrinking in flexbox */
}
.composer-send-lang-inline .composer-lang-btn:hover {
  background: var(--side-2);
  color: var(--ink);
}
.composer-send-lang-inline .composer-lang-btn .caret {
  margin-left: 2px;
  display: inline-block;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.6;
  transform: translateY(1px);
}
.composer-attach-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;            /* v42: don't shrink in flexbox */
}
.composer-attach-btn:hover { background: var(--side-2); color: var(--ink); }
.composer-attach-btn svg { width: 18px; height: 18px; }
.composer-input textarea {
  border: 0;
  background: transparent;
  outline: 0;
  resize: none;
  min-height: 32px;
  max-height: 200px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  padding: 4px 0;
  width: 0;                 /* v42: flexbox trick — width:0 + flex:1 = precise shrink */
  flex: 1 1 auto;
  min-width: 0;             /* allow textarea to shrink below content size */
  font-family: inherit;
  overflow-y: auto;
  scrollbar-width: thin;
}
/* v38: Bottom-edge resize handle for the message body textarea */
.composer-input-resize-handle {
  height: 6px;
  margin: -2px 0 -2px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: 0.5;
  transition: opacity 0.15s, height 0.12s;
}
.composer-input-resize-handle::before {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: var(--line-2);
  transition: background 0.15s, width 0.15s;
}
.composer-input-resize-handle:hover { opacity: 1; }
.composer-input-resize-handle:hover::before {
  background: var(--rail-active);
  width: 56px;
}
.composer-input-resize-handle.rz-active { opacity: 1; }
.composer-input-resize-handle.rz-active::before {
  background: var(--rail-active);
  width: 56px;
}
.composer-template-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;            /* v42: don't shrink in flexbox */
}
.composer-template-btn:hover { background: var(--side-2); color: var(--ink); }
.composer-template-btn svg { width: 18px; height: 18px; }
.composer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.composer-left-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.composer-send-lang-wrap { position: relative; z-index: 60; }
.composer-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.composer-lang-btn:hover { border-color: var(--rail-active); background: var(--surface-2); }
.composer-lang-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.composer-lang-btn .caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 2px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.6;
  transition: transform 0.15s;
}
.composer-lang-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.composer-lang-dropdown {
  position: fixed;
  width: 240px;
  max-height: 320px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.16), 0 2px 6px rgba(0,0,0,0.06);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.composer-lang-dropdown::after {
  content: "";
  position: absolute;
  left: 16px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  filter: drop-shadow(0 1px 0 var(--line));
}
.composer-lang-dropdown.lang-dropdown-above::after {
  bottom: -8px;
  border-top: 8px solid #fff;
  border-bottom: 0;
}
.composer-lang-dropdown.lang-dropdown-below::after {
  top: -8px;
  border-bottom: 8px solid #fff;
  border-top: 0;
}
.lang-list {
  overflow-y: auto;
  max-height: 320px;
  padding: 6px;
}
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  transition: background 0.12s;
}
.lang-option:hover { background: var(--surface-2); }
.lang-option.active { background: rgba(20, 184, 112, 0.1); color: var(--rail-active); font-weight: 600; }
.lang-option-name { flex: 1; }
.lang-option-code { font-size: 10px; color: var(--muted); text-transform: uppercase; padding: 2px 6px; background: var(--surface-2); border-radius: 4px; }
.lang-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 12px; }
.composer-actions #send {
  height: 34px;
  padding: 0 16px;
  border: 0;
  background: var(--rail-active);
  color: #fff;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.composer-actions #send:hover { background: #0a8a55; }
.composer-actions #send:disabled { opacity: 0.5; cursor: not-allowed; }
.composer-actions #send svg { width: 14px; height: 14px; }

/* Auto-translation display */
.auto-translation {
  margin-top: 4px;
  padding: 4px 8px;
  background: rgba(59, 130, 246, 0.08);
  border-left: 2px solid #3b82f6;
  border-radius: 4px;
  font-size: 12px;
  color: #1e40af;
  line-height: 1.4;
}
.auto-translation-label {
  font-size: 10px;
  font-weight: 600;
  color: #3b82f6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

/* ============================================================
   OTHER VIEWS
   ============================================================ */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--line);
}
.page-head small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.page-head h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  line-height: 1.2;
}
.page-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.outline-button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.outline-button:hover { background: var(--surface-2); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.card-head h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
}
.card-head span { font-size: 11px; color: var(--muted); }

/* Only apply auto-fit to tools/admin/device - NOT broadcast (it uses .broadcast-studio 2-col grid) */
.tools-grid, .admin-grid, .device-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
/* Broadcast grid: let .broadcast-studio handle layout */
.broadcast-grid {
  display: grid;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
label input, label select, label textarea {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}
label textarea { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }

button[type="submit"], .primary-button {
  height: 34px;
  padding: 0 16px;
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
button[type="submit"]:hover, .primary-button:hover { background: var(--brand-dark); }

.account-empty-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 24px;
  padding: 28px;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--line);
  margin: 24px auto;
  max-width: 880px;
  width: calc(100% - 32px);
  align-items: center;
}
.account-empty-panel .qr-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}
.account-empty-panel .qr-card img {
  width: 100%;
  height: auto;
  max-width: 360px;
  display: block;
}
.account-empty-panel .qr-card pre {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  text-align: center;
}
.account-empty-panel .qr-loading {
  color: var(--muted);
  font-size: 14px;
}
.account-empty-panel .qr-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.account-empty-panel .qr-actions button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.account-empty-panel .qr-actions button:hover { background: #fff; border-color: var(--brand); }
.account-empty-panel .qr-actions button.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.account-empty-copy small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.account-empty-copy h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}
.account-empty-copy p { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.account-empty-copy dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin: 0;
}
.account-empty-copy dt { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.account-empty-copy dd { font-size: 13px; color: var(--ink); margin: 0; word-break: break-all; }
.account-empty-qr {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
  min-height: 200px;
}
.account-empty-qr img { max-width: 240px; border-radius: 8px; }
.account-empty-qr pre {
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 12px;
  font-size: 10px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-width: 240px;
}
.connected-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.connected-hero strong { font-size: 16px; color: var(--ok); }
.connected-hero span { font-size: 11px; color: var(--muted); }
.qr-loading { color: var(--muted); font-size: 13px; }

/* ============================================================
   TOPBAR USER CHIP + AVATAR IMAGE OVERLAYS
   ============================================================ */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  height: 36px;
  min-width: 0;
  max-width: 200px;
  transition: all 0.15s ease;
  cursor: default;
}
.topbar-user:hover { background: var(--surface); border-color: var(--line-2); }
.topbar-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #14b870, #0a8a55);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}
.topbar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.1;
}
.topbar-user-meta strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.topbar-user-meta small {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.message-sender.has-operator::after {
  content: "✓";
  display: inline-block;
  margin-left: 4px;
  color: inherit;
  opacity: 0.65;
  font-size: 9px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ============================================================
   RESPONSIVE — desktop
   ============================================================ */

/* ---------- User dropdown (in icon rail) ---------- */
.rail-profile-wrap { position: relative; margin-top: auto; }
.rail-user-menu {
  display: none;
  position: absolute;
  left: calc(100% + 8px);
  bottom: 0;
  width: 200px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 8px;
  z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.rail-user-menu.is-open { display: block; }
.rail-user-menu-user {
  padding: 8px 10px;
  border-bottom: 1px solid #334155;
  margin-bottom: 6px;
}
.rail-user-menu-user strong { color: #f8fafc; font-size: 13px; display: block; }
.rail-user-menu-user small { color: #94a3b8; font-size: 11px; }
.rail-user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.rail-user-menu-item:hover { background: #334155; color: #f8fafc; }
.rail-user-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.rail-user-menu-lang { padding: 6px 10px; }
.rail-user-menu-lang select {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 12px;
}

/* ---------- Translation Settings Panel (v44) ---------- */
.translate-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 52px; /* icon-rail width */
  width: 280px;
  background: var(--surface-1, #fff);
  border-right: 1px solid var(--line, #e2e8f0);
  box-shadow: 4px 0 16px rgba(0,0,0,.08);
  z-index: 800;
  display: none;
  flex-direction: column;
}
.translate-panel:not([hidden]) { display: flex; }
.translate-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #0f172a);
}
.translate-panel-header button {
  width: 28px; height: 28px;
  border: 0; background: transparent;
  border-radius: 6px;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
}
.translate-panel-header button:hover { background: var(--side-2); color: var(--ink); }
.translate-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.translate-setting-group {
  margin-bottom: 20px;
}
.translate-setting-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink, #0f172a);
}
.translate-setting-group select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  color: var(--ink, #0f172a);
  font-size: 13px;
  transition: border-color .15s;
}
.translate-setting-group select:focus {
  outline: none;
  border-color: var(--rail-active, #14b8a6);
  box-shadow: 0 0 0 3px rgba(20,184,112,.1);
}
.translate-setting-group select:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.translate-panel-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line, #e2e8f0);
}
.ts-save-btn {
  width: 100%;
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg,#14b8a6,#0d9488);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.ts-save-btn:hover { opacity: .9; }
.ts-save-btn:active { transform: scale(.98); }

/* ─── Templates Panel (reuses .translate-panel) ─── */
.templates-panel { }
.tpl-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}
.tpl-form input,
.tpl-form textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: var(--surface-2, #f1f5f9);
  color: var(--ink, #1a1f2e);
  font-size: 12.5px;
  outline: 0;
}
.tpl-form textarea { resize: vertical; min-height: 48px; }
.tpl-form .ts-save-btn { width: auto; padding: 7px 14px; font-size: 12.5px; }
.tpl-list { display: flex; flex-direction: column; gap: 6px; }
.tpl-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: var(--surface-2, #f1f5f9);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tpl-item:hover { border-color: var(--rail-active, #14b8a6); background: var(--side-2, #e8faf5); }
.tpl-item strong { font-size: 12.5px; color: var(--ink, #1a1f2e); }
.tpl-item small { font-size: 11px; color: var(--muted, #64748b); }
.tpl-item span { font-size: 11.5px; color: var(--ink, #1a1f2e); opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-item-actions {
  display: flex; gap: 6px; margin-top: 4px;
}
.tpl-item-actions button {
  padding: 3px 8px; border: 0; border-radius: 6px;
  font-size: 11px; cursor: pointer;
  background: var(--side-2, #e8faf5); color: var(--rail-active, #14b8a6);
  transition: background .15s;
}
.tpl-item-actions button:hover { background: var(--rail-active, #14b8a6); color: #fff; }
.tpl-item-actions .tpl-del { background: #fee2e2; color: #dc2626; }
.tpl-item-actions .tpl-del:hover { background: #dc2626; color: #fff; }

/* Rail Templates button active state */
#rail-templates-btn.active {
  background: var(--rail-active-bg, rgba(20,184,166,.12));
  color: var(--rail-active, #14b8a6);
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  transition: .25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 17px; width: 17px;
  left: 2.5px; bottom: 2.5px;
  background: #fff;
  border-radius: 50%;
  transition: .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle-switch input:checked + .toggle-slider { background: #14b8a6; }
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}
/* v44: Hide old per-message translate buttons & inline lang dropdown */
.composer-send-lang-wrap { display: none !important; }
.message-translate-bar { display: none !important; }

/* ---------- Search in list toolbar ---------- */
.list-toolbar-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  flex: 1 1 auto;
  min-width: 0;
  height: 32px;
}
.list-toolbar-search svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.list-toolbar-search input {
  border: 0; background: transparent; outline: 0;
  font-size: 12.5px; color: var(--ink); width: 100%; min-width: 0;
}
.list-toolbar-search:focus-within {
  border-color: var(--rail-active);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 184, 112, 0.12);
}
@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 60px 200px minmax(0, 1fr) !important;
  }
  .chat-page { grid-template-columns: 320px minmax(0, 1fr) !important; }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 56px 200px minmax(0, 1fr) !important;
  }
  .rail-brand { width: 36px; height: 36px; font-size: 12px; }
  .rail-btn { width: 36px; height: 36px; }
  .rail-btn svg { width: 18px; height: 18px; }
  .topbar-search { min-width: 200px; }
  .chat-page { grid-template-columns: 300px minmax(0, 1fr) !important; }
  .topbar-user-meta { display: none; }
  .topbar-user { padding: 4px; }
}

/* ============================================================
   RESPONSIVE — TABLET (≤ 860px): collapse filter column
   ============================================================ */
@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 56px minmax(0, 1fr) !important;
    grid-template-rows: 56px minmax(0, 1fr) !important;
    grid-template-areas:
      "rail topbar"
      "rail content" !important;
  }
  .filter-column { display: none !important; }
  .topbar-search { min-width: 160px; }
  .topbar-title h1 { font-size: 15px; }
  .topbar-user-meta { display: flex; }
  .topbar-user { padding: 4px 10px 4px 4px; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 720px): dedicated mobile UI
   Single-pane navigation with back button.
   ============================================================ */
.chat-back-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.chat-back-btn svg { width: 18px; height: 18px; }
.mobile-filter-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-filter-toggle svg { width: 16px; height: 16px; }

@media (max-width: 720px) {
  body[data-view="chat"] .app-shell {
    grid-template-columns: 100% !important;
    grid-template-rows: 56px minmax(0, 1fr) !important;
    grid-template-areas:
      "topbar"
      "content" !important;
  }
  body[data-view="chat"] .icon-rail { display: none !important; }
  body[data-view="chat"] .topbar { padding: 0 8px !important; gap: 6px !important; }
  body[data-view="chat"] .topbar-title h1 { font-size: 14px; }
  body[data-view="chat"] .topbar-sub { display: none; }
  body[data-view="chat"] .topbar-lang { display: none; }
  body[data-view="chat"] .topbar-search { display: none; }
  body[data-view="chat"] #topbar-user { display: none; }
  body[data-view="chat"] #refresh { display: none; }

  /* mobile single-pane chat: when a conversation is active, hide the list and show the chat fullscreen */
  body[data-view="chat"][data-mobile-chat="active"] .chat-page {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }
  body[data-view="chat"][data-mobile-chat="active"] .list-column { display: none !important; }
  body[data-view="chat"][data-mobile-chat="active"] .filter-column { display: none !important; }
  body[data-view="chat"][data-mobile-chat="active"] .chat-back-btn { display: inline-flex; }
  body[data-view="chat"][data-mobile-chat="active"] .mobile-filter-toggle { display: none; }

  /* Default mobile state: list visible, chat hidden */
  body[data-view="chat"]:not([data-mobile-chat="active"]) .chat-column { display: none !important; }
  body[data-view="chat"]:not([data-mobile-chat="active"]) .list-column { border-right: 0; }
  body[data-view="chat"]:not([data-mobile-chat="active"]) .mobile-filter-toggle { display: inline-flex; }
  body[data-view="chat"]:not([data-mobile-chat="active"]) .filter-column.is-open { display: flex !important; }
  body[data-view="chat"]:not([data-mobile-chat="active"]) .filter-column {
    position: fixed;
    inset: 56px 0 0;
    z-index: 20;
    background: var(--surface);
    border-right: 0;
    border-top: 1px solid var(--line);
    width: 100% !important;
    grid-template-rows: auto 1fr;
    overflow: hidden;
    display: none;
  }
  body[data-view="chat"]:not([data-mobile-chat="active"]) .filter-column.is-open { display: flex !important; }
  body[data-view="chat"]:not([data-mobile-chat="active"]) .filter-column .account-list { overflow-y: auto; }

  body[data-view="chat"] .chat-page {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) !important;
  }
  body[data-view="chat"] .thread-head { padding: 6px 10px; min-height: 52px; }
  body[data-view="chat"] .messages { padding: 10px 8px; }
  body[data-view="chat"] .message { font-size: 14px; padding: 9px 12px; }
  body[data-view="chat"] .composer { padding: 8px; }
  body[data-view="chat"] .composer-textarea { font-size: 15px; min-height: 40px; }
  body[data-view="chat"] .send-button { width: 44px; height: 44px; }
  body[data-view="chat"] .page-wrap { padding: 12px 12px 24px; }
  body[data-view="chat"] .page-head h1 { font-size: 18px; }
  body[data-view="chat"] .page-head { padding: 0 0 10px; }
  body[data-view="chat"] .device-grid,
  body[data-view="chat"] .broadcast-grid,
  body[data-view="chat"] .tools-grid,
  body[data-view="chat"] .admin-grid {
    grid-template-columns: 1fr !important;
  }
  /* Bigger touch targets for rail buttons in mobile */
  body[data-view="chat"] .rail-btn { width: 44px; height: 44px; }
}

/* ============================================================
   RESPONSIVE — PHONES (≤ 420px)
   ============================================================ */
@media (max-width: 420px) {
  .app-shell { grid-template-columns: 48px minmax(0, 1fr) !important; }
  .rail-brand { width: 32px; height: 32px; font-size: 11px; }
  .rail-btn { width: 32px; height: 32px; }
  .rail-btn svg { width: 16px; height: 16px; }
  .topbar { padding: 0 10px !important; gap: 6px; }
  .topbar-search { min-width: 90px; padding: 4px 8px; height: 32px; }
  .topbar-btn { width: 32px; height: 32px; }
  .thread-head { padding: 8px 10px; }
  .thread-icon-btn span { display: none; }
  .messages { padding: 10px; }
  .composer { padding: 8px; }
}
.landing-html {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.landing-html body,
body.landing-body {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  background: #f6efe2;
  color: #10223a;
  font-family: "Aptos", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.onepage-home {
  --page-ink: #10223a;
  --page-muted: #69758b;
  --page-blue: #0f5bff;
  --page-green: #00a884;
  --page-coral: #ff6b3d;
  --page-cream: #fff7ea;
  --page-line: rgba(16,34,58,.12);
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(16,34,58,.045) 1px, transparent 1px),
    linear-gradient(180deg, #fff8ed 0%, #eef5ff 46%, #ffffff 100%);
  background-size: 64px 64px, auto;
}

.section-anchor {
  scroll-margin-top: 104px;
}

.onepage-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 82px;
  padding: 14px clamp(18px, 5vw, 76px);
  border-bottom: 1px solid rgba(255,255,255,.62);
  background: rgba(255,250,242,.92);
  box-shadow: 0 18px 50px rgba(16,34,58,.1);
  backdrop-filter: blur(18px);
}

.onepage-brand,
.onepage-nav a,
.onepage-actions a,
.hero-actions a,
.pricing-cards a,
.onepage-footer a {
  color: inherit;
  text-decoration: none;
}

.onepage-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-weight: 900;
}

.onepage-brand span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--page-green), var(--page-blue));
  color: #fff;
  box-shadow: 0 14px 28px rgba(15,91,255,.2);
}

.onepage-brand strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
  letter-spacing: -.01em;
}

.onepage-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.onepage-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 13px;
  border-radius: 999px;
  color: #243650;
  font-size: 14px;
  font-weight: 850;
  white-space: nowrap;
}

.onepage-nav a:hover {
  background: #fff;
  color: var(--page-blue);
  box-shadow: 0 8px 24px rgba(16,34,58,.08);
}

.onepage-actions,
.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.onepage-actions a,
.hero-actions a,
.pricing-cards a,
.contact-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 900;
}

.onepage-actions .solid,
.hero-actions .solid,
.pricing-cards .featured a,
.contact-form button {
  background: linear-gradient(135deg, var(--page-coral), #ff9c4b);
  color: #fff;
  box-shadow: 0 18px 34px rgba(255,107,61,.24);
}

.onepage-actions .ghost,
.hero-actions .ghost,
.pricing-cards a {
  border-color: var(--page-line);
  background: rgba(255,255,255,.76);
  color: var(--page-ink);
}

.one-hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 570px);
  gap: clamp(28px, 5vw, 76px);
  align-items: center;
  padding: clamp(128px, 15vw, 168px) clamp(18px, 5vw, 76px) clamp(70px, 8vw, 112px);
  overflow: hidden;
}

.one-hero::before {
  content: "";
  position: absolute;
  inset: 82px clamp(18px, 5vw, 76px) auto auto;
  width: min(44vw, 620px);
  height: 64%;
  border: 1px solid rgba(16,34,58,.08);
  border-radius: 44px;
  background:
    linear-gradient(135deg, rgba(15,91,255,.12), rgba(0,168,132,.08)),
    repeating-linear-gradient(135deg, rgba(255,255,255,.45) 0 12px, transparent 12px 24px);
  transform: skewY(-3deg);
}

.one-hero-copy,
.product-visual {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--page-green);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.one-hero h1 {
  max-width: 850px;
  margin: 0 0 22px;
  color: var(--page-ink);
  font-size: clamp(42px, 6vw, 86px);
  line-height: .98;
  letter-spacing: 0;
}

.hero-lede {
  max-width: 760px;
  margin: 0 0 28px;
  color: #4e5f78;
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.85;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 650px;
  margin-top: 32px;
}

.hero-metrics span,
.trust-band span,
.service-cards article,
.pricing-cards article,
.contact-form,
.contact-note,
.workflow-panel,
.product-window,
.floating-card {
  border: 1px solid rgba(16,34,58,.1);
  background: rgba(255,255,255,.78);
  box-shadow: 0 18px 46px rgba(16,34,58,.08);
}

.hero-metrics span {
  display: grid;
  gap: 4px;
  min-height: 86px;
  align-content: center;
  padding: 14px;
  border-radius: 20px;
}

.hero-metrics b {
  color: var(--page-blue);
  font-size: 25px;
  line-height: 1;
}

.hero-metrics small {
  color: var(--page-muted);
  font-weight: 800;
}

.product-visual {
  min-height: 560px;
  display: grid;
  place-items: center;
}

.product-window {
  width: min(100%, 560px);
  border-radius: 30px;
  overflow: hidden;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(20px);
}

.product-window-top {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--page-line);
}

.product-window-top i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #d7deea;
}

.product-window-top i:first-child {
  background: var(--page-coral);
}

.product-window-top i:nth-child(2) {
  background: var(--page-green);
}

.product-window-top strong {
  margin-left: auto;
  color: var(--page-muted);
  font-size: 13px;
}

.product-window-body {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  min-height: 430px;
}

.product-window-body aside {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 18px;
  background: #10223a;
}

.product-window-body aside b,
.product-window-body aside span {
  display: block;
  padding: 11px 12px;
  border-radius: 14px;
  color: rgba(255,255,255,.72);
  font-size: 13px;
  font-weight: 900;
}

.product-window-body aside b {
  background: #fff;
  color: var(--page-blue);
}

.product-window-body section {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 22px;
  background: #f7f9fc;
}

.message-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--page-line);
  border-radius: 20px;
  background: #fff;
}

.message-card.active {
  border-color: rgba(0,168,132,.28);
  background: #effcf8;
}

.message-card small,
.message-card em,
.mini-grid small {
  color: var(--page-muted);
  font-style: normal;
}

.message-card strong {
  overflow-wrap: anywhere;
  font-size: 17px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mini-grid span {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 14px;
  border-radius: 18px;
  background: #10223a;
  color: #fff;
}

.mini-grid b {
  font-size: 24px;
}

.floating-card {
  position: absolute;
  display: grid;
  gap: 3px;
  min-width: 180px;
  padding: 16px 18px;
  border-radius: 20px;
  background: #fff;
}

.floating-card span {
  color: var(--page-muted);
  font-size: 13px;
  font-weight: 750;
}

.card-top {
  top: 78px;
  right: -8px;
}

.card-bottom {
  left: -10px;
  bottom: 84px;
}

.trust-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 0 clamp(18px, 5vw, 76px) 72px;
}

.trust-band span {
  display: grid;
  place-items: center;
  min-height: 62px;
  border-radius: 18px;
  color: #31425c;
  font-weight: 900;
}

.one-section,
.contact-section {
  padding: clamp(74px, 9vw, 126px) clamp(18px, 5vw, 76px);
}

.section-intro {
  max-width: 840px;
  margin: 0 auto 38px;
  text-align: center;
}

.section-intro.left {
  margin: 0;
  text-align: left;
}

.section-intro h2,
.contact-copy h2 {
  margin: 0 0 16px;
  color: var(--page-ink);
  font-size: clamp(34px, 4.5vw, 62px);
  line-height: 1.08;
  letter-spacing: 0;
}

.section-intro p,
.contact-copy p {
  margin: 0;
  color: var(--page-muted);
  font-size: 17px;
}

.service-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.service-cards article {
  min-height: 255px;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 26px;
  border-radius: 26px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.service-cards article:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 64px rgba(16,34,58,.13);
}

.service-cards span {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: #10223a;
  color: #fff;
  font-weight: 950;
}

.service-cards h3,
.pricing-cards h3,
.contact-form h3 {
  margin: 0;
  color: var(--page-ink);
  font-size: 23px;
}

.service-cards p,
.pricing-cards p {
  margin: 0;
  color: var(--page-muted);
}

.split-section {
  display: grid;
  grid-template-columns: minmax(320px, .86fr) minmax(0, 1fr);
  gap: clamp(26px, 5vw, 76px);
  align-items: center;
  background:
    linear-gradient(135deg, rgba(16,34,58,.96), rgba(15,91,255,.82)),
    #10223a;
  color: #fff;
}

.split-section .section-intro h2,
.split-section .section-intro p {
  color: #fff;
}

.workflow-panel {
  display: grid;
  gap: 14px;
  padding: 26px;
  border-color: rgba(255,255,255,.18);
  border-radius: 30px;
  background: rgba(255,255,255,.1);
  box-shadow: 0 28px 70px rgba(0,0,0,.18);
}

.workflow-panel div {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 78px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.12);
}

.workflow-panel b {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #fff;
  color: var(--page-blue);
}

.workflow-panel span {
  font-size: 17px;
  font-weight: 900;
}

.feature-list {
  display: grid;
  gap: 10px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.feature-list li {
  padding: 13px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.9);
  font-weight: 800;
}

.pricing-one {
  background: #fff;
}

.pricing-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.pricing-cards article {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 320px;
  padding: 30px;
  border-radius: 28px;
}

.pricing-cards article.featured {
  background: #10223a;
  color: #fff;
  transform: translateY(-10px);
}

.pricing-cards small {
  color: var(--page-green);
  font-weight: 950;
  letter-spacing: .14em;
}

.pricing-cards strong {
  color: var(--page-coral);
  font-size: clamp(42px, 5vw, 64px);
  line-height: 1;
}

.pricing-cards .featured h3,
.pricing-cards .featured p {
  color: #fff;
}

.contact-section {
  display: grid;
  grid-template-columns: minmax(300px, .86fr) minmax(360px, 560px);
  gap: clamp(28px, 5vw, 76px);
  align-items: start;
  background:
    linear-gradient(90deg, rgba(15,91,255,.08) 1px, transparent 1px),
    linear-gradient(180deg, #eef5ff, #fff8ed);
  background-size: 48px 48px, auto;
}

.contact-copy {
  position: sticky;
  top: 118px;
}

.contact-note {
  display: grid;
  gap: 7px;
  margin-top: 26px;
  padding: 20px;
  border-radius: 22px;
}

.contact-note span {
  color: var(--page-muted);
}

.contact-form {
  display: grid;
  gap: 16px;
  padding: clamp(22px, 4vw, 34px);
  border-radius: 30px;
}

.contact-form .form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.contact-form label {
  display: grid;
  gap: 7px;
  color: #33445c;
  font-size: 13px;
  font-weight: 900;
}

.contact-form input,
.contact-form select,
.contact-form textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(16,34,58,.14);
  border-radius: 16px;
  background: #fff;
  color: var(--page-ink);
  padding: 11px 13px;
  font-size: 15px;
}

.contact-form textarea {
  resize: vertical;
}

.contact-form button {
  width: 100%;
  border: 0;
  font-size: 16px;
}

.form-success,
.form-error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 16px;
  font-weight: 900;
}

.form-success {
  background: #e6fbf3;
  color: #087453;
}

.form-error {
  background: #fff0ed;
  color: #bd3f28;
}

.onepage-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 34px clamp(18px, 5vw, 76px);
  background: #10223a;
  color: #fff;
}

.onepage-footer p {
  max-width: 720px;
  margin: 8px 0 0;
  color: rgba(255,255,255,.66);
}

.onepage-footer nav {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.onepage-footer a {
  color: rgba(255,255,255,.78);
  font-weight: 850;
}

.contact-leads-card {
  grid-column: 1 / -1;
}

.lead-message {
  max-width: 860px;
  margin-top: 8px !important;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(16,34,58,.05);
}

@media (max-width: 1120px) {
  .onepage-header {
    grid-template-columns: 1fr auto;
  }

  .onepage-nav {
    grid-column: 1 / -1;
    order: 3;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .one-hero {
    grid-template-columns: 1fr;
    padding-top: 164px;
  }

  .one-hero::before {
    width: 82vw;
    height: 42%;
  }

  .product-visual {
    min-height: 500px;
  }

  .service-cards,
  .pricing-cards,
  .contact-section,
  .split-section {
    grid-template-columns: 1fr;
  }

  .contact-copy {
    position: static;
  }
}

@media (max-width: 760px) {
  .section-anchor {
    scroll-margin-top: 142px;
  }

  .onepage-header {
    gap: 10px;
    padding: 10px 14px;
  }

  .onepage-brand strong {
    font-size: 15px;
  }

  .onepage-actions {
    justify-content: flex-end;
  }

  .onepage-actions a {
    min-height: 38px;
    padding: 0 12px;
    font-size: 12px;
  }

  .one-hero {
    min-height: auto;
    padding: 154px 16px 58px;
  }

  .one-hero h1 {
    font-size: clamp(36px, 11vw, 52px);
  }

  .hero-lede {
    font-size: 16px;
  }

  .hero-actions,
  .onepage-actions {
    gap: 8px;
  }

  .hero-actions a {
    flex: 1 1 160px;
  }

  .hero-metrics,
  .trust-band,
  .mini-grid,
  .contact-form .form-row {
    grid-template-columns: 1fr;
  }

  .trust-band,
  .one-section,
  .contact-section {
    padding-left: 16px;
    padding-right: 16px;
  }

  .product-visual {
    min-height: 0;
    place-items: stretch;
  }

  .product-window-body {
    grid-template-columns: 1fr;
  }

  .product-window-body aside {
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .floating-card {
    position: static;
    margin-top: 12px;
  }

  .service-cards article,
  .pricing-cards article {
    min-height: auto;
  }

  .pricing-cards article.featured {
    transform: none;
  }

  .onepage-footer {
    grid-template-columns: 1fr;
  }
}

/* App shell v9: scrollable console pages and refined broadcast studio */
.app-html {
  min-height: 100%;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.app-html body:not(.landing-body):not(.login-body) {
  min-height: 100%;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    linear-gradient(135deg, rgba(14,116,109,.08), transparent 32%),
    linear-gradient(180deg, #f7f0e6 0%, #eef2f0 100%);
  color: #15231f;
  font-family: "Aptos", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

.app-html .app-shell {
  min-height: 100dvh;
  height: auto;
  grid-template-rows: auto minmax(calc(100dvh - 68px), auto);
  overflow: visible;
}

.app-html body[data-view="chat"] .app-shell {
  min-height: 100dvh;
  height: 100dvh;
  grid-template-rows: 68px minmax(0, 1fr);
  overflow: hidden;
}

.app-html body:not([data-view="chat"]) .topbar {
  position: sticky;
  top: 0;
  z-index: 90;
}

.app-html .view {
  min-height: 0;
  overflow: visible;
}

.app-html .view.active {
  /* Use 100% (not auto) so the view fills its flex parent (content-area),
     otherwise the view collapses to its content's height and leaves
     a blank strip below. */
  height: 100%;
  flex: 1 1 auto;
  overflow: hidden;
}

.app-html body[data-view="chat"] #chat-view.active {
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.app-html body:not([data-view="chat"]) .side {
  display: none !important;
}

.app-html body:not([data-view="chat"]) .page-head {
  border-bottom: 1px solid rgba(49,63,57,.12);
  background: rgba(255,250,242,.94);
  backdrop-filter: blur(16px);
}

.app-html #devices-view.active,
.app-html #broadcast-view.active,
.app-html #tools-view.active,
.app-html #admin-view.active {
  padding-bottom: 36px;
}

.app-html .device-grid,
.app-html .broadcast-grid,
.app-html .tools-grid,
.app-html .admin-grid {
  align-items: start;
  overflow: visible;
}

.app-html .card,
.app-html .device-card,
.app-html .account-form,
.app-html .login-panel {
  border: 1px solid rgba(54,70,63,.12);
  background: rgba(255,253,248,.92);
  box-shadow: 0 18px 48px rgba(34,43,39,.08);
}

.app-html body[data-view="broadcast"] .broadcast-studio {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.broadcast-console-card {
  position: sticky;
  top: 150px;
}

.broadcast-console-card .card-head {
  align-items: flex-start;
  background:
    linear-gradient(135deg, rgba(14,116,109,.12), transparent 48%),
    rgba(255,250,242,.96);
}

.broadcast-console-card .card-head small {
  display: block;
  margin-top: 4px;
  color: #69756f;
  font-size: 12px;
  font-weight: 750;
}

.broadcast-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 6px;
  border: 1px solid rgba(14,116,109,.16);
  border-radius: 18px;
  background: #f3eadc;
}

.broadcast-mode-tabs label {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 72px;
  align-content: center;
  padding: 12px 14px 12px 44px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255,255,255,.54);
  color: #15231f;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.broadcast-mode-tabs label:hover {
  transform: translateY(-1px);
  border-color: rgba(14,116,109,.22);
}

.broadcast-mode-tabs label.active {
  border-color: rgba(14,116,109,.42);
  background: #fffdf8;
  box-shadow: 0 12px 24px rgba(14,116,109,.12);
}

.broadcast-mode-tabs input {
  position: absolute;
  left: 16px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: 0;
  transform: translateY(-50%);
  accent-color: var(--brand);
}

.broadcast-mode-tabs span {
  color: #10231f;
  font-size: 14px;
  font-weight: 950;
}

.broadcast-mode-tabs small {
  color: #6f7871;
  font-size: 11px;
  font-weight: 750;
}

.broadcast-preview-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(14,116,109,.16);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(14,116,109,.1), transparent 56%),
    #fffdf8;
}

.broadcast-preview-panel small {
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.broadcast-preview-panel strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.broadcast-preview-panel p {
  margin: 5px 0 0;
  color: #6c766f;
  font-size: 12px;
}

.broadcast-preview-panel > span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 210px;
  padding: 0 12px;
  border-radius: 999px;
  background: #163b36;
  color: #fff8ec;
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.app-html .broadcast-form {
  gap: 12px;
  padding: 16px;
}

.app-html .broadcast-form textarea {
  min-height: 150px;
}

.app-html .strategy-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: #f6ecd9;
}

body[data-broadcast-mode="manual"] .schedule-field {
  opacity: .55;
}

body[data-broadcast-mode="manual"] .schedule-field input {
  pointer-events: none;
}

body[data-broadcast-mode="schedule"] .broadcast-preview-panel > span {
  background: linear-gradient(135deg, #405bb7, #0f7cdb);
}

.app-html #broadcast-send {
  min-height: 48px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 950;
}

.app-html .target-list,
.app-html .template-list,
.app-html .jobs,
.app-html .user-list,
.app-html .permission-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(14,116,109,.45) transparent;
}

.app-html .target-row,
.app-html .template-item,
.app-html .job,
.app-html .user-row {
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.app-html .target-row:hover,
.app-html .template-item:hover,
.app-html .job:hover,
.app-html .user-row:hover {
  transform: translateY(-1px);
  border-color: rgba(14,116,109,.3);
  background: #fffdf8;
  box-shadow: 0 12px 26px rgba(34,43,39,.08);
}

.app-html .jobs-card {
  margin: 0 18px 18px;
}

@media (max-width: 1180px) {
  .app-html body[data-view="broadcast"] .broadcast-studio {
    grid-template-columns: 1fr 1fr;
  }

  .broadcast-console-card {
    position: static;
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-html body:not([data-view="chat"]) .app-shell {
    min-height: 100dvh;
    height: auto;
    grid-template-rows: auto auto;
    padding-bottom: 0;
    overflow: visible;
  }

  .app-html body:not([data-view="chat"]) .topbar {
    position: sticky;
    top: 0;
    max-height: none;
    overflow: visible;
  }

  .app-html body:not([data-view="chat"]) .view.active {
    min-height: calc(100dvh - 120px);
    height: auto;
    overflow: visible;
  }

  .app-html body:not([data-view="chat"]) .page-head {
    top: 0;
    z-index: 30;
  }

  .app-html body[data-view="chat"] .app-shell {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  .app-html .broadcast-studio,
  .app-html .device-grid,
  .app-html .tools-grid,
  .app-html .admin-grid {
    grid-template-columns: 1fr;
  }

  .broadcast-mode-tabs,
  .broadcast-preview-panel,
  .app-html .strategy-grid {
    grid-template-columns: 1fr;
  }

  .broadcast-preview-panel > span {
    justify-content: center;
    max-width: none;
    width: 100%;
  }
}

/* App shell v10: mobile left navigation and polished language switch */
.app-html .language-control {
  position: relative;
  display: inline-grid;
  grid-template-columns: auto minmax(86px, auto);
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 4px 8px 4px 10px;
  border: 1px solid rgba(14,116,109,.18);
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(14,116,109,.08), transparent 50%),
    #fffdf8;
  box-shadow: 0 10px 22px rgba(34,43,39,.06);
}

.app-html .language-control > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff8ec;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0;
}

.app-html .language-control .language-select {
  min-height: 30px;
  width: 100%;
  min-width: 86px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #17342f;
  font-weight: 900;
  padding: 0 24px 0 0;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #17342f 50%),
    linear-gradient(135deg, #17342f 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 13px,
    calc(100% - 8px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.app-html .language-control .language-select:focus {
  outline: 0;
}

@media (max-width: 760px) {
  .app-html body:not(.landing-body):not(.login-body) {
    overflow-x: hidden;
  }

  .app-html .app-shell,
  .app-html body[data-view="chat"] .app-shell,
  .app-html body:not([data-view="chat"]) .app-shell {
    width: calc(100vw - 78px);
    margin-left: 78px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "content";
  }

  .app-html body[data-view="chat"] .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .app-html body:not([data-view="chat"]) .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .app-html .topbar,
  .app-html body:not([data-view="chat"]) .topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    max-height: none;
    padding: 10px;
    overflow: visible;
    border-left: 1px solid rgba(93,76,53,.12);
  }

  .app-html .brand {
    grid-template-columns: 38px minmax(0, 1fr);
    min-width: 0;
  }

  .app-html .brand strong {
    font-size: 13px;
  }

  .app-html .brand small {
    font-size: 10px;
  }

  .app-html .top-nav {
    position: fixed;
    z-index: 120;
    inset: 0 auto 0 0;
    width: 78px;
    height: 100dvh;
    display: grid;
    grid-auto-rows: minmax(68px, auto);
    grid-template-columns: 1fr;
    align-content: start;
    gap: 7px;
    padding: max(10px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom));
    border: 0;
    border-right: 1px solid rgba(14,116,109,.18);
    border-radius: 0;
    background:
      linear-gradient(180deg, rgba(255,250,242,.98), rgba(244,234,218,.96)),
      #fff8ed;
    box-shadow: 18px 0 40px rgba(34,43,39,.12);
    overflow-y: auto;
    overflow-x: hidden;
    backdrop-filter: blur(18px);
  }

  .app-html .top-nav::before {
    content: "MENU";
    display: grid;
    place-items: center;
    min-height: 28px;
    color: #6c776f;
    font-size: 9px;
    font-weight: 950;
    letter-spacing: .12em;
  }

  .app-html .nav-button {
    width: 100%;
    min-width: 0;
    min-height: 64px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 28px auto;
    place-items: center;
    gap: 5px;
    padding: 8px 4px;
    border-radius: 18px;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    text-align: center;
  }

  .app-html .nav-button:hover {
    transform: none;
    background: rgba(255,255,255,.66);
  }

  .app-html .nav-button.active,
  .app-html .nav-button.active:hover {
    border-color: rgba(14,116,109,.28);
    background: linear-gradient(135deg, #173c37, var(--brand));
    box-shadow: 0 12px 22px rgba(14,116,109,.2);
  }

  .app-html .nav-button .nav-icon {
    grid-row: auto;
    width: 30px;
    height: 30px;
    border-radius: 12px;
  }

  .app-html .nav-button span {
    max-width: 100%;
    color: #24352f;
    font-size: 10px;
    line-height: 1.1;
    font-weight: 950;
    overflow-wrap: anywhere;
  }

  .app-html .nav-button.active span {
    color: #fff8ec;
  }

  .app-html .nav-button small {
    display: none;
  }

  .app-html .app-actions,
  .app-html .user-menu {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(88px, auto);
    gap: 8px;
    align-items: stretch;
  }

  .app-html .language-control {
    grid-column: 1 / -1;
    width: 100%;
    grid-template-columns: auto minmax(0, 1fr);
    min-height: 42px;
  }

  .app-html .language-control .language-select {
    min-width: 0;
  }

  .app-html .profile-button {
    min-width: 0;
    width: 100%;
    max-width: none;
    justify-content: start;
    padding: 0 12px;
  }

  .app-html .user-menu > button[type="submit"] {
    min-width: 82px;
    padding: 0 10px;
  }

  .app-html .view.active {
    grid-area: content;
  }

  .app-html body:not([data-view="chat"]) .page-head {
    top: 0;
  }

  .app-html .chat-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(218px, 42%) minmax(0, 1fr);
  }

  .app-html .module-head,
  .app-html .thread-head,
  .app-html .page-head,
  .app-html .card-head {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (max-width: 420px) {
  .app-html .app-shell,
  .app-html body[data-view="chat"] .app-shell,
  .app-html body:not([data-view="chat"]) .app-shell {
    width: calc(100vw - 70px);
    margin-left: 70px;
  }

  .app-html .top-nav {
    width: 70px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .app-html .nav-button {
    min-height: 60px;
    border-radius: 16px;
  }

  .app-html .nav-button span {
    font-size: 9px;
  }
}

/* App shell v11: compact mobile account/language bar */
@media (max-width: 760px) {
  .app-html .app-actions,
  .app-html .user-menu {
    display: grid;
    grid-template-columns: minmax(88px, 1fr) minmax(74px, .9fr) 54px;
    gap: 6px;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .app-html .language-control {
    grid-column: auto;
    min-width: 0;
    width: 100%;
    min-height: 38px;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 6px;
    padding: 4px 7px;
  }

  .app-html .language-control > span {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }

  .app-html .language-control .language-select {
    min-width: 0;
    height: 28px;
    padding-right: 18px;
    font-size: 12px;
    background-position:
      calc(100% - 10px) 12px,
      calc(100% - 6px) 12px;
    background-size: 4px 4px, 4px 4px;
  }

  .app-html .profile-button {
    min-width: 0;
    width: 100%;
    height: 38px;
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    padding: 0 9px;
    border-radius: 999px;
  }

  .app-html .profile-button span {
    display: none;
  }

  .app-html .profile-button strong {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    font-size: 12px;
  }

  .app-html .logout-button {
    width: 54px;
    min-width: 0;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
  }

  .app-html .logout-button span {
    display: none;
  }

  .app-html .logout-button::before {
    content: "Exit";
    font-size: 11px;
    font-weight: 950;
  }

  .app-html .brand {
    margin-bottom: 0;
  }
}

@media (max-width: 420px) {
  .app-html .app-actions,
  .app-html .user-menu {
    grid-template-columns: minmax(78px, 1fr) minmax(62px, .86fr) 48px;
    gap: 5px;
  }

  .app-html .language-control {
    grid-template-columns: 22px minmax(0, 1fr);
    padding-left: 6px;
    padding-right: 6px;
  }

  .app-html .language-control > span {
    width: 22px;
    height: 22px;
    font-size: 8px;
  }

  .app-html .language-control .language-select {
    font-size: 11px;
  }

  .app-html .profile-button,
  .app-html .logout-button {
    height: 36px;
    min-height: 36px;
  }

  .app-html .logout-button {
    width: 48px;
  }

  .app-html .logout-button::before {
    content: "Out";
    font-size: 10px;
  }
}

/* App shell v12: hamburger dropdown menu for mobile */
.menu-toggle {
  display: none;
}

@media (max-width: 760px) {
  .app-html .app-shell,
  .app-html body[data-view="chat"] .app-shell,
  .app-html body:not([data-view="chat"]) .app-shell {
    width: 100%;
    margin-left: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "content";
  }

  .app-html .topbar,
  .app-html body:not([data-view="chat"]) .topbar {
    grid-template-columns: minmax(0, 1fr) 46px;
    grid-template-areas:
      "brand toggle"
      "actions actions"
      "nav nav";
    align-items: center;
    gap: 9px;
    padding: 10px;
    border-left: 0;
    border-bottom: 1px solid rgba(14,116,109,.16);
    background:
      linear-gradient(135deg, rgba(14,116,109,.08), transparent 42%),
      rgba(255,250,242,.97);
    box-shadow: 0 14px 34px rgba(34,43,39,.1);
  }

  .app-html .brand {
    grid-area: brand;
    min-width: 0;
    margin: 0;
  }

  .app-html .menu-toggle {
    grid-area: toggle;
    display: grid;
    place-items: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(14,116,109,.22);
    border-radius: 16px;
    background: #fffdf8;
    box-shadow: 0 10px 22px rgba(34,43,39,.08);
  }

  .app-html .menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #17342f;
    transition: transform .18s ease, opacity .18s ease;
  }

  .app-html body.menu-open .menu-toggle {
    background: linear-gradient(135deg, #173c37, var(--brand));
    border-color: rgba(14,116,109,.4);
  }

  .app-html body.menu-open .menu-toggle span {
    background: #fff8ec;
  }

  .app-html body.menu-open .menu-toggle span:first-child {
    transform: translateY(6px) rotate(45deg);
  }

  .app-html body.menu-open .menu-toggle span:nth-child(2) {
    opacity: 0;
  }

  .app-html body.menu-open .menu-toggle span:last-child {
    transform: translateY(-6px) rotate(-45deg);
  }

  .app-html .app-actions,
  .app-html .user-menu {
    grid-area: actions;
    display: grid;
    grid-template-columns: minmax(96px, 1fr) minmax(78px, .86fr) 54px;
    gap: 7px;
    width: 100%;
    min-width: 0;
    align-items: center;
  }

  .app-html .language-control {
    grid-column: auto;
    min-width: 0;
    width: 100%;
    height: 40px;
    min-height: 40px;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 6px;
    padding: 4px 8px;
    border-color: rgba(14,116,109,.2);
    background: #fffdf8;
    color: #17342f;
    box-shadow: 0 8px 18px rgba(34,43,39,.05);
  }

  .app-html .language-control .language-select {
    color: #17342f;
    font-size: 12px;
    font-weight: 950;
  }

  .app-html .profile-button {
    width: 100%;
    height: 40px;
    min-height: 40px;
    max-width: none;
    border: 1px solid rgba(14,116,109,.22);
    background: #fffdf8;
    color: #17342f;
    box-shadow: 0 8px 18px rgba(34,43,39,.05);
  }

  .app-html .profile-button span {
    display: none;
  }

  .app-html .profile-button strong {
    color: #17342f;
    font-weight: 950;
  }

  .app-html .logout-button {
    width: 54px;
    height: 40px;
    min-height: 40px;
    border: 0;
    border-radius: 999px;
    background: #17342f;
    color: #fff8ec;
    box-shadow: 0 10px 22px rgba(23,52,47,.18);
  }

  .app-html .logout-button::before {
    content: "Exit";
    color: #fff8ec;
  }

  .app-html .top-nav {
    grid-area: nav;
    position: static;
    inset: auto;
    width: 100%;
    height: auto;
    max-height: min(58dvh, 430px);
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(14,116,109,.14);
    border-radius: 22px;
    background:
      linear-gradient(135deg, rgba(14,116,109,.08), transparent 50%),
      #fffdf8;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
    overflow: auto;
  }

  .app-html body.menu-open .top-nav {
    display: grid;
    animation: mobile-menu-drop .16s ease-out both;
  }

  @keyframes mobile-menu-drop {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .app-html .top-nav::before {
    content: "MAIN MENU";
    display: block;
    min-height: auto;
    padding: 0 4px 2px;
    color: #69756f;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: .14em;
    text-align: left;
  }

  .app-html .nav-button {
    min-height: 58px;
    width: 100%;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 10px;
    justify-items: start;
    align-items: center;
    padding: 9px 12px;
    border: 1px solid rgba(14,116,109,.12);
    border-radius: 16px;
    background: rgba(255,255,255,.68);
    text-align: left;
  }

  .app-html .nav-button .nav-icon {
    grid-row: 1 / span 2;
    width: 32px;
    height: 32px;
  }

  .app-html .nav-button span {
    color: #17342f;
    font-size: 13px;
    line-height: 1.05;
  }

  .app-html .nav-button small {
    display: block;
    color: #6c776f;
    font-size: 10px;
    line-height: 1.1;
  }

  .app-html .nav-button.active,
  .app-html .nav-button.active:hover {
    background: linear-gradient(135deg, #173c37, var(--brand));
    border-color: rgba(14,116,109,.42);
  }

  .app-html .nav-button.active span,
  .app-html .nav-button.active small {
    color: #fff8ec;
  }

  .app-html body:not([data-view="chat"]) .page-head {
    top: 0;
  }
}

@media (max-width: 420px) {
  .app-html .app-shell,
  .app-html body[data-view="chat"] .app-shell,
  .app-html body:not([data-view="chat"]) .app-shell {
    width: 100%;
    margin-left: 0;
  }

  .app-html .app-actions,
  .app-html .user-menu {
    grid-template-columns: minmax(82px, 1fr) minmax(64px, .82fr) 48px;
  }

  .app-html .logout-button {
    width: 48px;
  }

  .app-html .logout-button::before {
    content: "Out";
  }
}

/* App shell v13: rebuilt system header */
.app-html {
  --workspace-header-height: 0;
}

.app-html .workspace-header {
  grid-area: topbar;
  position: sticky;
  top: 0;
  z-index: 120;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 12px;
  min-height: var(--workspace-header-height);
  padding: 14px clamp(14px, 2vw, 22px) 12px;
  border: 0;
  border-bottom: 1px solid rgba(21,35,31,.1);
  background:
    linear-gradient(135deg, rgba(14,116,109,.1), transparent 38%),
    linear-gradient(180deg, rgba(255,253,248,.98), rgba(247,239,228,.96));
  box-shadow: 0 18px 50px rgba(34,43,39,.12);
  backdrop-filter: blur(18px);
}

.app-html .workspace-primary {
  display: grid;
  grid-template-columns: minmax(260px, auto) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.app-html .workspace-brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 12px;
  align-items: center;
  min-width: 0;
  padding: 0;
  color: #132a25;
}

.app-html .workspace-brand > span {
  grid-row: 1 / span 2;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.34), transparent 28%),
    linear-gradient(135deg, #173c37, var(--brand));
  color: #fff8ec;
  box-shadow: 0 14px 28px rgba(14,116,109,.24);
}

.app-html .workspace-brand strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #132a25;
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 0;
}

.app-html .workspace-brand small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #6a756f;
  font-size: 11px;
  font-weight: 800;
}

.app-html .workspace-actions {
  justify-self: end;
  display: grid;
  grid-template-columns: minmax(126px, auto) minmax(150px, auto) auto;
  gap: 9px;
  align-items: center;
  min-width: 0;
}

.app-html .workspace-header .language-control {
  min-height: 42px;
  height: 42px;
  grid-template-columns: 28px minmax(76px, 1fr);
  border-color: rgba(14,116,109,.18);
  background: #fffdf8;
}

.app-html .workspace-header .language-control > span {
  width: 28px;
  height: 28px;
}

.app-html .workspace-header .profile-button,
.app-html .workspace-header .logout-button {
  height: 42px;
  min-height: 42px;
  border-radius: 999px;
  font-weight: 950;
}

.app-html .workspace-header .profile-button {
  max-width: none;
  min-width: 150px;
  border: 1px solid rgba(14,116,109,.18);
  background: #fffdf8;
  color: #17342f;
}

.app-html .workspace-header .profile-button span,
.app-html .workspace-header .profile-button strong {
  color: #17342f;
}

.app-html .workspace-header .logout-button {
  min-width: 88px;
  border: 0;
  background: #17342f;
  color: #fff8ec;
  box-shadow: 0 12px 24px rgba(23,52,47,.2);
}

.app-html .workspace-header .logout-button span {
  color: #fff8ec;
}

.app-html .workspace-header .logout-button::before {
  display: none;
}

.app-html .workspace-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(14,116,109,.12);
  border-radius: 24px;
  background: rgba(255,255,255,.52);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.76);
}

.app-html .workspace-nav::before {
  display: none;
}

.app-html .workspace-nav .nav-button {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.app-html .workspace-nav .nav-button:hover {
  transform: translateY(-1px);
  border-color: rgba(14,116,109,.18);
  background: rgba(255,255,255,.72);
}

.app-html .workspace-nav .nav-button.active,
.app-html .workspace-nav .nav-button.active:hover {
  border-color: rgba(14,116,109,.42);
  background: linear-gradient(135deg, #173c37, var(--brand));
  box-shadow: 0 14px 26px rgba(14,116,109,.2);
}

.app-html .workspace-nav .nav-button .nav-icon {
  grid-row: 1 / span 2;
  width: 34px;
  height: 34px;
  border-radius: 13px;
}

.app-html .workspace-nav .nav-button span {
  color: #17342f;
  font-size: 13px;
  font-weight: 950;
}

.app-html .workspace-nav .nav-button small {
  display: block;
  color: #69756f;
  font-size: 10px;
  font-weight: 800;
}

.app-html .workspace-nav .nav-button.active span,
.app-html .workspace-nav .nav-button.active small {
  color: #fff8ec;
}

/* v43+ NOTE: Non-chat views use single-row grid ("rail content").
   Only chat view keeps 2-row (topbar row removed visually via display:none).
   Do NOT override grid-template-rows to 2 rows here — it breaks non-chat layouts. */
.app-html .app-shell,
.app-html body[data-view="chat"] .app-shell {
  width: 100%;
  margin-left: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: visible;
}
/* Exclude non-chat from the 2-row override above */
.app-html body:not([data-view="chat"]) .app-shell {
  grid-template-rows: minmax(0, 1fr) !important;
  overflow: hidden !important;
}

.app-html body[data-view="chat"] .app-shell {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

.app-html body[data-view="chat"] #chat-view.active {
  max-height: calc(100dvh - var(--workspace-header-height));
}

.app-html body[data-view="chat"] .chat-page,
.app-html body[data-view="chat"] .list-column {
  max-height: calc(100dvh - var(--workspace-header-height));
}

.app-html body[data-view="chat"] .conversation-list {
  max-height: calc(100dvh - var(--workspace-header-height) - 116px);
}

.app-html body:not([data-view="chat"]) .page-head {
  top: var(--workspace-header-height);
}

@media (max-width: 1120px) {
  .app-html .workspace-primary {
    grid-template-columns: minmax(220px, 1fr) auto;
  }

  .app-html .workspace-actions {
    grid-column: 1 / -1;
    justify-self: stretch;
    grid-template-columns: minmax(120px, .8fr) minmax(150px, 1fr) auto;
  }

  .app-html .workspace-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-html {
    --workspace-header-height: 0;
  }

  .app-html .workspace-header,
  .app-html body:not([data-view="chat"]) .workspace-header {
    grid-template-rows: auto auto auto;
    min-height: var(--workspace-header-height);
    gap: 8px;
    padding: 9px 10px 10px;
  }

  .app-html .workspace-primary {
    grid-template-columns: minmax(0, 1fr) 44px;
    grid-template-areas:
      "brand toggle"
      "actions actions";
    gap: 8px;
  }

  .app-html .workspace-brand {
    grid-area: brand;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 1px 10px;
  }

  .app-html .workspace-brand > span {
    width: 40px;
    height: 40px;
    border-radius: 14px;
  }

  .app-html .workspace-brand strong {
    font-size: 14px;
  }

  .app-html .workspace-brand small {
    font-size: 10px;
  }

  .app-html .menu-toggle {
    grid-area: toggle;
    display: grid;
    place-items: center;
    gap: 4px;
    width: 44px;
    height: 44px;
  }

  .app-html .workspace-actions {
    grid-area: actions;
    grid-column: auto;
    display: grid;
    grid-template-columns: minmax(94px, 1fr) minmax(76px, .86fr) 54px;
    gap: 7px;
    align-items: center;
    width: 100%;
  }

  .app-html .workspace-header .language-control,
  .app-html .workspace-header .profile-button,
  .app-html .workspace-header .logout-button {
    height: 38px;
    min-height: 38px;
  }

  .app-html .workspace-header .language-control {
    grid-template-columns: 24px minmax(0, 1fr);
    padding: 4px 7px;
  }

  .app-html .workspace-header .language-control > span {
    width: 24px;
    height: 24px;
    font-size: 9px;
  }

  .app-html .workspace-header .language-select {
    min-width: 0;
    font-size: 12px;
  }

  .app-html .workspace-header .profile-button {
    min-width: 0;
    display: grid;
    place-items: center;
    padding: 0 9px;
  }

  .app-html .workspace-header .profile-button span {
    display: none;
  }

  .app-html .workspace-header .profile-button strong {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    font-size: 12px;
  }

  .app-html .workspace-header .logout-button {
    width: 54px;
    min-width: 0;
    padding: 0;
  }

  .app-html .workspace-header .logout-button span {
    display: none;
  }

  .app-html .workspace-header .logout-button::before {
    display: block;
    content: "Exit";
    color: #fff8ec;
    font-size: 11px;
    font-weight: 950;
  }

  .app-html .workspace-nav {
    display: none;
    grid-template-columns: 1fr;
    max-height: min(58dvh, 430px);
    overflow: auto;
    border-radius: 20px;
    padding: 9px;
  }

  .app-html body.menu-open .workspace-nav {
    display: grid;
    animation: mobile-menu-drop .16s ease-out both;
  }

  .app-html .workspace-nav::before {
    content: "MAIN MENU";
    display: block;
    padding: 0 4px 2px;
    color: #69756f;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: .14em;
  }

  .app-html .workspace-nav .nav-button {
    min-height: 58px;
  }

  .app-html body.menu-open {
    --workspace-header-height: min(78dvh, 560px);
  }

  .app-html body[data-view="chat"] #chat-view.active,
  .app-html body[data-view="chat"] .chat-page,
  .app-html body[data-view="chat"] .list-column {
    max-height: calc(100dvh - 56px);
  }

  .app-html body[data-view="chat"] .conversation-list {
    max-height: calc(100dvh - 172px);
  }

  .app-html body:not([data-view="chat"]) .page-head {
    top: 0;
  }
}

@media (max-width: 420px) {
  .app-html .workspace-actions {
    grid-template-columns: minmax(82px, 1fr) minmax(62px, .82fr) 48px;
    gap: 5px;
  }

  .app-html .workspace-header .logout-button {
    width: 48px;
  }

  .app-html .workspace-header .logout-button::before {
    content: "Out";
    font-size: 10px;
  }
}

/* App shell v14: faster message feel, chat avatars, refined account filter */
.app-html .account-list {
  gap: 9px;
}

.app-html .account-chip {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(39,51,47,.12);
  border-radius: 16px;
  background: rgba(255,253,248,.78);
  color: #1d2b27;
  box-shadow: 0 10px 22px rgba(34,43,39,.04);
}

.app-html .account-chip::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: transparent;
}

.app-html .account-chip:hover {
  border-color: rgba(39,51,47,.22);
  background: #fffdf8;
  transform: translateY(-1px);
}

.app-html .account-chip.active {
  border-color: rgba(39,51,47,.28);
  background:
    linear-gradient(135deg, rgba(255,255,255,.96), rgba(250,246,238,.94)),
    #fffdf8;
  color: #14231f;
  box-shadow: 0 14px 30px rgba(34,43,39,.1);
}

.app-html .account-chip.active::before {
  background: #263733;
}

.app-html .account-chip.active strong {
  color: #14231f;
}

.app-html .state-dot.logged_in,
.app-html .state-dot.connected,
.app-html .state-dot.online {
  background: #257c55;
  box-shadow: 0 0 0 3px rgba(37,124,85,.12);
}

.app-html .avatar,
.app-html .message-avatar {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  text-transform: uppercase;
}

.app-html .avatar::after,
.app-html .message-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 18%, rgba(255,255,255,.36), transparent 26%),
    linear-gradient(135deg, rgba(255,255,255,.08), transparent 52%);
  z-index: -1;
}

.app-html .avatar-single,
.app-html .avatar-inbound {
  background: linear-gradient(135deg, #36566d, #5883a2);
  color: #fff;
}

.app-html .avatar-group {
  border-radius: 14px;
  background: linear-gradient(135deg, #6750a4, #3876d6);
  color: #fff;
}

.app-html .avatar-status {
  background: linear-gradient(135deg, #e8b44f, #f4d98b);
  color: #4f3411;
}

.app-html .avatar-outbound {
  background: linear-gradient(135deg, #173c37, #0e746d);
  color: #fff8ec;
}

.app-html .message-row {
  display: grid;
  grid-template-columns: 36px minmax(0, max-content);
  gap: 9px;
  align-items: end;
  max-width: min(760px, 92%);
}

.app-html .message-row.outbound {
  align-self: flex-end;
  grid-template-columns: minmax(0, max-content) 36px;
}

.app-html .message-row.outbound .message-avatar {
  grid-column: 2;
  grid-row: 1;
}

.app-html .message-row.outbound .message {
  grid-column: 1;
  grid-row: 1;
}

.app-html .message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 13px;
  box-shadow: 0 10px 20px rgba(34,43,39,.12);
  font-size: 12px;
  font-weight: 950;
}

.app-html .message-row .message {
  max-width: min(660px, 100%);
}

.app-html .message-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  color: #65716b;
  font-size: 11px;
  font-weight: 800;
}

.app-html .message.outbound .message-meta {
  color: rgba(255,248,236,.72);
}

.message-loading {
  margin: auto;
  display: grid;
  place-items: center;
  gap: 8px;
  min-width: 210px;
  padding: 22px;
  border: 1px solid rgba(39,51,47,.12);
  border-radius: 22px;
  background: rgba(255,253,248,.86);
  color: #65716b;
  box-shadow: 0 18px 44px rgba(34,43,39,.08);
}

.message-loading span {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 2px;
  border-radius: 999px;
  background: #173c37;
  animation: message-dot .82s ease-in-out infinite alternate;
}

.message-loading span:nth-child(2) {
  animation-delay: .12s;
}

.message-loading span:nth-child(3) {
  animation-delay: .24s;
}

.message-loading strong {
  color: #2b3935;
  font-size: 13px;
}

@keyframes message-dot {
  from { opacity: .28; transform: translateY(0); }
  to { opacity: 1; transform: translateY(-5px); }
}

.messages-refreshing {
  align-self: center;
  margin: 4px 0 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,253,248,.82);
  color: #65716b;
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-html .message-row {
    max-width: 96%;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 7px;
  }

  .app-html .message-row.outbound {
    grid-template-columns: minmax(0, 1fr) 30px;
  }

  .app-html .message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 11px;
    font-size: 11px;
  }

  .app-html .message-row .message {
    max-width: 100%;
  }
}

/* ==========================================================================
   whatplus v3 — 4-Column Layout Override
   HTML: icon-rail(64) + topbar(full) + filter-column(220) + content-area(1fr)
   Old CSS was written for 2-col (topbar + side + content). The override below
   brings the new HTML structure to life without touching the rest of the file.
   ========================================================================== */

/* ---------- Desktop: 4-column shell ---------- */
.app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: 64px 220px minmax(0, 1fr);
  grid-template-rows: 56px minmax(0, 1fr);
  grid-template-areas:
    "rail topbar topbar"
    "rail filter content";
  overflow: hidden;
  background: #eeeeea;
}

/* ---------- Icon Rail (left menu, 64px) ---------- */
.icon-rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  background: #0f0f10;
  color: #d4d4d8;
  border-right: 1px solid #1f1f23;
}
.rail-brand {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #14b870, #0a8a55);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  text-decoration: none;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(20, 184, 112, 0.25);
}
.rail-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  position: relative;
}
.rail-btn:hover {
  background: #1c1c20;
  color: #fff;
}
.rail-btn.active {
  background: #14b870;
  color: #fff;
  box-shadow: 0 4px 12px rgba(20, 184, 112, 0.3);
}
.rail-btn.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #14b870;
  border-radius: 0 2px 2px 0;
}
.rail-btn svg { width: 20px; height: 20px; }
.rail-spacer { flex: 1; }
.rail-btn.is-hidden { display: none; }
.rail-profile {
  font-weight: 700;
  font-size: 14px;
  color: #d4d4d8;
}

/* ---------- Topbar (full width header) ---------- */
.topbar {
  grid-area: topbar;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: #111;
}
.topbar-left { min-width: 0; }
.topbar-title h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  line-height: 1.1;
}
.topbar-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}
.topbar-search {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fafafa;
  min-width: 240px;
  color: var(--muted);
}
.topbar-search svg { width: 16px; height: 16px; }
.topbar-search input {
  border: 0;
  background: transparent;
  outline: 0;
  font-size: 13px;
  color: #111;
  width: 100%;
}
.topbar-search:focus-within {
  border-color: #14b870;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 184, 112, 0.12);
}
.topbar-lang {
  height: 32px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  background: #fff;
  color: #111;
  cursor: pointer;
}
.topbar-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.topbar-btn:hover { background: #f5f5f5; color: #111; }
.topbar-btn svg { width: 16px; height: 16px; }
.topbar-logout-form { display: inline-flex; }

/* ---------- Filter Column (account list) ---------- */
.filter-column {
  grid-area: filter;
  min-height: 0;
  background: #fdfdfb;
  border-right: 1px solid var(--line);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}
.filter-section { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 0;
}
.filter-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.filter-count {
  font-size: 11px;
  background: #f1f1ec;
  color: #555;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
#accounts { flex: 1; min-height: 0; overflow: auto; }

/* ---------- Content Area (main) ---------- */
.content-area {
  grid-area: content;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #eeeeea;
}
.content-area > .view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.content-area > .view.active {
  display: flex;
  flex-direction: column;
}
.content-area > .view.active > .page-wrap,
.content-area > .view.active > .chat-page {
  flex: 1;
  min-height: 0;
}

/* Override the .view global rule that pinned grid-area: content */
.view { grid-area: auto; display: none; }
.view.active { display: flex; flex-direction: column; }

/* ---------- Hide legacy side panel ---------- */
.side { display: none !important; }

/* ---------- List column refinements ---------- */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.list-head h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #111;
}
.list-head-actions { display: flex; gap: 4px; }
.list-icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #555;
}
.list-icon-btn:hover { background: #f1f1ec; color: #111; }
.list-icon-btn svg { width: 16px; height: 16px; }

.filter-pills {
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
  flex-wrap: wrap;
}
.list-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fafaf7;
}
.list-select {
  height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  background: #fff;
  color: #111;
}

/* ---------- Thread head inside chat column ---------- */
.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.thread-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #14b870, #0a8a55);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.thread-meta { min-width: 0; }
.thread-meta h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  line-height: 1.1;
  color: #111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #94a3b8;
}
.status-dot.online { background: #14b870; }
.thread-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.thread-select {
  height: 30px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  background: #fff;
  color: #111;
  max-width: 140px;
}
.thread-icon-btn {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  color: #555;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
}
.thread-icon-btn:hover { background: #f5f5f5; color: #111; }
.thread-icon-btn svg { width: 14px; height: 14px; }

/* ---------- Responsive: tablet (≤ 980px) ---------- */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 56px 200px minmax(0, 1fr);
  }
  .topbar-search { min-width: 180px; }
  .chat-page { grid-template-columns: 320px minmax(0, 1fr); }
}

/* ---------- Responsive: mobile (≤ 720px) ---------- */
@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-rows: 56px minmax(0, 1fr);
    grid-template-areas:
      "rail topbar"
      "rail content";
  }
  .filter-column { display: none; }
  .topbar-search { min-width: 140px; }
  .topbar-title h1 { font-size: 14px; }
  .topbar-sub { display: none; }
  .chat-page { grid-template-columns: 1fr; grid-template-rows: minmax(220px, 38dvh) minmax(0, 1fr); }
}

/* ---------- Responsive: small phone (≤ 480px) ---------- */
@media (max-width: 480px) {
  .app-shell { grid-template-columns: 52px minmax(0, 1fr); }
  .rail-brand { width: 36px; height: 36px; font-size: 12px; }
  .rail-btn { width: 36px; height: 36px; }
  .rail-btn svg { width: 18px; height: 18px; }
  .topbar { padding: 6px 10px; gap: 6px; }
  .topbar-search { min-width: 100px; padding: 4px 8px; }
  .topbar-lang { display: none; }
}

/* ============================================================
   App shell v18: card styles + QR centered
   - device-card, user-row, job, template-item card chrome
   - account-empty-panel single column centered QR
   - jobs-card / user-stat-row / template-helper polish
   ============================================================ */

/* ---- Shared card chrome for list items ---- */
.app-html .device-card,
.app-html .user-row,
.app-html .job,
.app-html .template-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(54,70,63,.12);
  border-radius: 14px;
  background: rgba(255,253,248,.92);
  box-shadow: 0 8px 22px rgba(34,43,39,.04);
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  width: 100%;
  min-width: 0;
  position: relative;
}

.app-html .device-card > header,
.app-html .user-row > div,
.app-html .job > header,
.app-html .template-item {
  display: block;
}

.app-html .device-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(54,70,63,.12);
}
.app-html .device-card > header h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--ink);
  word-break: break-word;
}
.app-html .device-card > header p {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  word-break: break-all;
}
.app-html .device-card > header > span {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.app-html .device-card.is-online > header > span {
  background: rgba(20,184,112,.12);
  color: #0a8a55;
}
.app-html .device-card.needs-login > header > span {
  background: rgba(220,90,90,.1);
  color: #b14b4b;
}

.app-html .device-card > dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 14px;
  margin: 0;
  font-size: 12px;
}
.app-html .device-card > dl > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.app-html .device-card > dl dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.app-html .device-card > dl dd {
  margin: 0;
  font-size: 12px;
  color: var(--ink);
  word-break: break-all;
}

.app-html .device-card > footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding-top: 6px;
  border-top: 1px dashed rgba(54,70,63,.12);
}
.app-html .device-card > footer button,
.app-html .device-card > footer span {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(54,70,63,.16);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
}
.app-html .device-card > footer button:hover {
  border-color: var(--brand);
  background: #fff;
}
.app-html .device-card > footer span.connected-note {
  background: rgba(20,184,112,.12);
  border-color: rgba(20,184,112,.3);
  color: #0a8a55;
  font-weight: 600;
  cursor: default;
}
.app-html .device-card > footer button.danger-button {
  color: #b14b4b;
  border-color: rgba(177,75,75,.3);
}
.app-html .device-card > footer button.danger-button:hover {
  background: rgba(177,75,75,.08);
  border-color: #b14b4b;
}

/* ---- User row (admin user list) ---- */
.app-html .user-row {
  gap: 12px;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  min-height: 96px;
}
.app-html .user-row > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
}
.app-html .user-row > div strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}
.app-html .user-row > div small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.app-html .user-row > div p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}
.app-html .user-row .user-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.app-html .user-row .user-stat-row span {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}
.app-html .user-row .row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}
.app-html .user-row .row-actions button {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(54,70,63,.16);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
}
.app-html .user-row .row-actions button:hover {
  border-color: var(--brand);
}
.app-html .user-row .row-actions button.danger-button {
  color: #b14b4b;
  border-color: rgba(177,75,75,.3);
}
.app-html .user-row .row-actions button.outline-button {
  background: var(--surface-2);
}

/* ---- Job (broadcast history) ---- */
.app-html .job {
  gap: 8px;
}
.app-html .job > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.app-html .job > header strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}
.app-html .job > header .status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  color: var(--muted);
}
.app-html .job > header .status.finished,
.app-html .job > header .status.completed {
  background: rgba(20,184,112,.12);
  color: #0a8a55;
}
.app-html .job > header .status.running,
.app-html .job > header .status.processing {
  background: rgba(245,158,11,.14);
  color: #b56b08;
}
.app-html .job > header .status.failed,
.app-html .job > header .status.error {
  background: rgba(220,90,90,.12);
  color: #b14b4b;
}
.app-html .job > p {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
  word-break: break-word;
  white-space: pre-wrap;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(54,70,63,.08);
}
.app-html .job > small {
  font-size: 11px;
  color: var(--muted);
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  display: block;
  word-break: break-word;
}
.app-html .job .job-targets {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.app-html .job .target-status {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  border-left: 3px solid var(--muted);
  word-break: break-word;
}
.app-html .job .target-status.sent,
.app-html .job .target-status.completed {
  border-left-color: #0a8a55;
  background: rgba(20,184,112,.06);
}
.app-html .job .target-status.failed,
.app-html .job .target-status.error {
  border-left-color: #b14b4b;
  background: rgba(220,90,90,.06);
}

/* ---- Template item (broadcast template list) ---- */
.app-html .template-item {
  cursor: pointer;
  gap: 6px;
  font-family: inherit;
}
.app-html .template-item strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
  display: block;
}
.app-html .template-item small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: block;
}
.app-html .template-item span {
  font-size: 12px;
  color: var(--ink);
  word-break: break-word;
  display: block;
  background: var(--surface-2);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(54,70,63,.08);
  white-space: pre-wrap;
  max-height: 100px;
  overflow: auto;
}

/* ---- Jobs card header layout fix ---- */
.app-html .jobs-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0;
}
.app-html .jobs-card > .card-head {
  padding: 12px 18px;
  margin: 0;
}
.app-html .jobs-card .jobs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 18px 18px;
  overflow: visible;
}

/* ---- User list spacing ---- */
.app-html .user-list,
.app-html .target-list,
.app-html .template-list,
.app-html .permission-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  overflow: visible;
}

/* ---- Account empty panel: single column centered QR ---- */
.app-html .account-empty-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px 28px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--line);
  margin: 24px auto;
  max-width: 480px;
  width: calc(100% - 32px);
  text-align: center;
}
.app-html .account-empty-panel .account-empty-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.app-html .account-empty-panel .account-empty-copy small {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  margin: 0;
}
.app-html .account-empty-panel .account-empty-copy h3 {
  font-size: 24px;
  font-weight: 700;
  margin: 4px 0 4px;
  color: var(--ink);
  word-break: break-word;
}
.app-html .account-empty-panel .account-empty-copy p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 4px;
  line-height: 1.5;
  max-width: 360px;
}
.app-html .account-empty-panel .account-empty-copy dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 12px;
  text-align: left;
  width: 100%;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 10px;
}
.app-html .account-empty-panel .account-empty-copy dt {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  align-self: center;
}
.app-html .account-empty-panel .account-empty-copy dd {
  font-size: 13px;
  color: var(--ink);
  margin: 0;
  word-break: break-all;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
}
.app-html .account-empty-panel .qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0;
  width: 100%;
}
.app-html .account-empty-panel .qr-actions button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
}
.app-html .account-empty-panel .qr-actions button:hover {
  background: #fff;
  border-color: var(--brand);
}
.app-html .account-empty-panel .qr-actions button.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.app-html .account-empty-panel .qr-actions button.primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.app-html .account-empty-panel .account-empty-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 320px;
  min-height: 0;
  margin: 0;
}
.app-html .account-empty-panel .qr-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}
.app-html .account-empty-panel .qr-card img {
  width: 100%;
  height: auto;
  max-width: 280px;
  display: block;
}
.app-html .account-empty-panel .qr-card pre {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
  text-align: center;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  padding: 8px;
}
.app-html .account-empty-panel .qr-loading {
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
}
.app-html .account-empty-panel .connected-hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
  padding: 24px 12px;
}
.app-html .account-empty-panel .connected-hero strong {
  font-size: 16px;
  color: var(--ok);
}
.app-html .account-empty-panel .connected-hero span {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
}

/* ---- Broadcast: form rows & helper text ---- */
.app-html .template-form,
.app-html .broadcast-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.app-html .template-form .form-row,
.app-html .broadcast-form .form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.app-html .template-form textarea,
.app-html .broadcast-form textarea {
  min-height: 110px;
  resize: vertical;
}
.app-html .template-helper {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px dashed rgba(54,70,63,.12);
  line-height: 1.5;
  word-break: break-word;
}
.app-html .template-helper code {
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  font-size: 11px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(54,70,63,.08);
}
.app-html .safety-copy {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 3px solid var(--brand);
  line-height: 1.5;
  margin: 0;
}

/* ---- Broadcast 2-column layout: left (3 input cards) | right (console + jobs) ---- */
.app-html body[data-view="broadcast"] .broadcast-studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* ---- Jobs / user list / billing list sections polish ---- */
.app-html .jobs-card {
  margin: 18px;
}
.app-html .admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1.4fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}

/* ---- Make sure button[type=submit] inside broadcast-form is full width on small ---- */
.app-html #broadcast-send,
.app-html #save-template {
  width: 100%;
  margin-top: 4px;
}

/* ============================================================
   App shell v19: chat list account filter + load older messages
   ============================================================ */

/* ---- Mobile filter toggle: only show on small screens ---- */
.mobile-filter-toggle {
  display: none;
}

/* ---- List sort select (account filter moved to left sidebar) ---- */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  position: relative;
  z-index: 2;
}
.list-toolbar .list-select {
  width: auto;
  min-width: 100px;
  max-width: 140px;
}

/* ---- Messages pane: ensure scroll works on touch devices ---- */
.messages {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}
.messages .messages-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
  justify-content: flex-end;
}

/* ---- Load older button: top of messages list ---- */
.messages-load-older {
  display: flex;
  justify-content: center;
  padding: 10px 12px 4px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: linear-gradient(180deg, var(--bg) 70%, transparent 100%);
  pointer-events: none;
  flex-shrink: 0;
}
.messages-load-older-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34,43,39,.06);
  transition: background 0.12s, transform 0.06s;
}
.messages-load-older-btn:hover { background: var(--surface-2, #f6f7f3); }
.messages-load-older-btn:active { transform: scale(0.97); }
.messages-load-older-btn svg { width: 14px; height: 14px; }
.messages-load-older-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: messages-spin 0.7s linear infinite;
}
@keyframes messages-spin { to { transform: rotate(360deg); } }

/* ---- Mobile chat: ensure thread-head / messages / composer are full height and scrollable ---- */
@media (max-width: 720px) {
  body[data-view="chat"][data-mobile-chat="active"] .chat-column {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  body[data-view="chat"] .messages {
    /* iOS Safari needs explicit height to allow scroll inside flex/grid */
    height: 100%;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
  /* Make load older button larger on mobile for touch */
  .messages-load-older-btn {
    padding: 8px 18px;
    font-size: 13px;
  }
}

/* ---- list-account-filter has proper color in dark mode + selected state ---- */
.list-select:focus {
  outline: 2px solid rgba(54, 70, 63, 0.25);
  outline-offset: 1px;
}

/* ============================================================
   v22: Broadcast Center — clean 2-column studio layout
   - Left column: stacked 3 input cards (Target Groups / Personal / Templates)
   - Right column: Send Console (sticky on desktop)
   - Below: full-width Job History
   ============================================================ */

body[data-view="broadcast"] .page-wrap {
  padding: 20px 24px 32px;
  gap: 18px;
}

body[data-view="broadcast"] .page-head {
  padding: 4px 4px 14px;
}

body[data-view="broadcast"] .page-head h1 {
  font-size: 24px;
  letter-spacing: -0.01em;
}

body[data-view="broadcast"] .page-head p {
  font-size: 13px;
  margin-top: 6px;
}

/* ============================================================
   v37: Broadcast Center — true left-right 2-column layout
   - Left column (.broadcast-left-col): 3 input cards stacked
   - Right column (.broadcast-right-col): Send Console (sticky) + Job History
   ============================================================ */

/* ---- Broadcast studio: 2 columns (left | right) ---- */
body[data-view="broadcast"] .broadcast-studio {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

/* Left column: stacked 3 input cards */
body[data-view="broadcast"] .broadcast-left-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* Right column: console + jobs */
body[data-view="broadcast"] .broadcast-right-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

/* All cards in broadcast-studio */
body[data-view="broadcast"] .broadcast-studio .card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Send Console: NOT sticky — let Job History follow naturally in the flex column */
body[data-view="broadcast"] .broadcast-right-col .broadcast-console-card {
  align-self: stretch;
  max-height: none;
  overflow: visible;
  position: static;
}

/* ---- Mobile: stack vertically ---- */
@media (max-width: 899px) {
  body[data-view="broadcast"] .broadcast-studio {
    grid-template-columns: 1fr;
  }
  body[data-view="broadcast"] .broadcast-right-col .broadcast-console-card {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
}

/* ---- Card heads: more breathing room + clean separator ---- */
body[data-view="broadcast"] .card-head {
  padding: 14px 18px;
  gap: 12px;
}

body[data-view="broadcast"] .card-head h2 {
  font-size: 15px;
  letter-spacing: -0.01em;
}

body[data-view="broadcast"] .card-head > div h2 + small {
  display: block;
  margin-top: 2px;
  color: #6f7871;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

body[data-view="broadcast"] .card-head > div small {
  display: block;
  margin-top: 4px;
  color: #69756f;
  font-size: 12px;
  font-weight: 600;
}

body[data-view="broadcast"] .card-head span {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(14, 116, 109, .08);
  color: var(--brand-dark);
  font-weight: 700;
}

/* ---- Target list (group rows) ---- */
body[data-view="broadcast"] .target-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
}

body[data-view="broadcast"] .target-list:empty::before {
  content: "No groups available. Open Device Manager and save groups first.";
  display: block;
  padding: 18px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed rgba(54, 70, 63, .12);
  border-radius: 10px;
  line-height: 1.5;
}

/* ---- Target row ---- */
body[data-view="broadcast"] .target-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(54, 70, 63, .12);
  border-radius: 10px;
  background: rgba(255, 253, 248, .92);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

body[data-view="broadcast"] .target-row:hover {
  border-color: rgba(14, 116, 109, .3);
  background: #fffdf8;
  transform: translateY(-1px);
}

body[data-view="broadcast"] .target-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  flex-shrink: 0;
  cursor: pointer;
}

body[data-view="broadcast"] .target-row .target-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

body[data-view="broadcast"] .target-row strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-word;
}

body[data-view="broadcast"] .target-row small {
  font-size: 11px;
  color: var(--muted);
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  word-break: break-all;
}

body[data-view="broadcast"] .target-row .target-count {
  font-size: 11px;
  color: var(--brand-dark);
  font-weight: 700;
  flex-shrink: 0;
  padding: 2px 8px;
  background: rgba(14, 116, 109, .1);
  border-radius: 999px;
}

/* ============================================================
   v40: Global checkbox polish — 18px, accent color, cursor pointer
   Applied to all checkboxes inside .app-html
   ============================================================ */
.app-html input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  accent-color: var(--brand, #0e746d);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  vertical-align: middle;
}

.app-html input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(14, 116, 109, .35);
  outline-offset: 1px;
}

.app-html input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* ============================================================
   v40: Group row (Devices view, inside .group-manager)
   - Reuse .target-row visual style so the checkbox is always visible
   ============================================================ */
.app-html .group-manager {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  margin-top: 8px;
  border: 1px solid rgba(54, 70, 63, .12);
  border-radius: 12px;
  background: rgba(255, 253, 248, .62);
}

.app-html .group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(54, 70, 63, .12);
  border-radius: 10px;
  background: rgba(255, 253, 248, .92);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.app-html .group-row:hover {
  border-color: rgba(14, 116, 109, .3);
  background: #fffdf8;
  transform: translateY(-1px);
}

.app-html .group-row > input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  accent-color: var(--brand, #0e746d);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.app-html .group-row > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.app-html .group-row > span strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #15231f);
  word-break: break-word;
}

.app-html .group-row > span small {
  font-size: 11px;
  color: var(--muted, #69756f);
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  word-break: break-all;
}

/* ============================================================
   v66: Full-screen settings, templates, account and tool pages
   ============================================================ */
body[data-view="tools"] .page-wrap,
body[data-view="settings"] .page-wrap,
body[data-view="message_templates"] .page-wrap,
body[data-view="account"] .page-wrap,
body[data-view="pricing"] .page-wrap {
  padding: 18px 22px 28px;
  gap: 16px;
  background: linear-gradient(180deg, #f7f4ee 0%, #f4f7f5 42%, #eef3f2 100%);
}

.app-page-head,
body[data-view="tools"] .page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 14px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 16px 44px rgba(15, 23, 42, .06);
}

.app-page-head small,
body[data-view="tools"] .page-head small {
  display: block;
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

.app-page-head h1,
body[data-view="tools"] .page-head h1 {
  margin: 0;
  color: #12201d;
  font-size: 24px;
  line-height: 1.15;
}

.app-page-head p,
body[data-view="tools"] .page-head p {
  margin: 5px 0 0;
  color: #69756f;
  font-size: 13px;
}

.tools-grid-full,
.settings-layout,
.template-workspace,
.account-dashboard,
.plan-grid-app {
  width: 100%;
}

.tools-grid-full {
  display: block;
  min-height: 0;
}

.tool-card-full {
  min-height: calc(100vh - 168px);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.tool-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.tool-controls label,
.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #52615b;
  font-size: 12px;
  font-weight: 700;
}

.tool-controls select,
.settings-form input,
.settings-form select,
.settings-form textarea,
.team-seat-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(15, 23, 42, .12);
  border-radius: 10px;
  background: #fff;
  color: #13231f;
  padding: 9px 12px;
  outline: 0;
}

.settings-form textarea {
  min-height: 160px;
  resize: vertical;
}

.tool-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.tool-summary-strip > div {
  padding: 13px 14px;
  border: 1px solid rgba(14, 116, 109, .13);
  border-radius: 12px;
  background: #f8fffc;
}

.tool-summary-strip strong {
  display: block;
  color: var(--brand);
  font-size: 24px;
  line-height: 1;
}

.tool-summary-strip span {
  display: block;
  margin-top: 4px;
  color: #69756f;
  font-size: 12px;
}

.tool-group-list {
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 12px;
  background: #fff;
}

.tool-table {
  min-width: 760px;
}

.tool-table-head,
.tool-group-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 120px;
  gap: 14px;
  align-items: center;
}

.tool-table-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  background: #f8faf9;
  color: #61716b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tool-table-head label,
.tool-group-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tool-group-row {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(15, 23, 42, .06);
  cursor: pointer;
  transition: background .14s ease;
}

.tool-group-row:hover {
  background: #f8fffc;
}

.tool-group-row.disabled {
  opacity: .58;
}

.tool-group-row strong,
.message-template-row strong {
  display: block;
  color: #14241f;
  font-size: 13px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-group-row small,
.message-template-row small {
  display: block;
  margin-top: 2px;
  color: #728079;
  font-size: 11px;
  word-break: break-all;
}

.tool-group-row em {
  color: #41524c;
  font-style: normal;
  font-weight: 700;
}

.tool-group-row b {
  justify-self: start;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(14, 116, 109, .1);
  color: var(--brand);
  font-size: 11px;
}

.tool-group-row.disabled b {
  background: rgba(100, 116, 139, .12);
  color: #64748b;
}

.settings-layout,
.template-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 16px;
  align-items: start;
}

.settings-card,
.template-editor-card,
.template-list-card {
  min-height: 0;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-row-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 18px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 12px;
  background: #fbfcfb;
}

.setting-row-card strong {
  color: #13231f;
  font-size: 15px;
}

.setting-row-card p {
  margin: 4px 0 0;
  color: #69756f;
  font-size: 13px;
}

.setting-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.settings-actions,
.team-seat-row,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-actions button,
.team-seat-row button,
.plan-card-app button,
.row-actions button,
.tool-controls button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #0e746d, #0ba36d);
  color: #fff;
  padding: 0 16px;
  font-weight: 750;
}

.settings-actions .outline-button,
.outline-button,
.row-actions .danger-button {
  border: 1px solid rgba(15, 23, 42, .12);
  background: #fff;
  color: #22332e;
}

.row-actions .danger-button {
  color: #b42318;
}

.profile-facts,
.usage-grid {
  display: grid;
  gap: 10px;
  margin: 0;
}

.profile-facts div,
.usage-grid div {
  padding: 12px;
  border-radius: 10px;
  background: #f8faf9;
}

.profile-facts dt,
.usage-grid dt {
  color: #728079;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-facts dd,
.usage-grid dd {
  margin: 3px 0 0;
  color: #13231f;
  font-weight: 750;
  word-break: break-word;
}

.template-token-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.template-token-row button {
  min-height: 30px;
  border: 1px solid rgba(14, 116, 109, .22);
  border-radius: 999px;
  background: #f0fdf8;
  color: var(--brand);
  font-weight: 750;
}

.message-template-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-template-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 12px;
  background: #fff;
}

.message-template-row p {
  margin: 6px 0 0;
  color: #52615b;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.account-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.account-hero-card {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 20px;
  border-radius: 16px;
  background: linear-gradient(135deg, #10221d, #0e746d);
  color: #fff;
  box-shadow: 0 18px 52px rgba(14, 116, 109, .22);
}

.account-avatar-large {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
  font-size: 24px;
  font-weight: 850;
}

.account-hero-card h2 {
  margin: 2px 0;
  font-size: 24px;
}

.account-hero-card p,
.account-hero-card small {
  margin: 0;
  color: rgba(255, 255, 255, .78);
}

.account-expiry-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  font-weight: 800;
}

.account-expiry-pill.is-expired {
  background: #fee2e2;
  color: #991b1b;
}

.usage-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.team-seat-row {
  margin-bottom: 12px;
}

.team-seat-row input {
  max-width: 120px;
}

.plan-grid-app {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.plan-card-app {
  padding: 18px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 14px;
  background: #fff;
}

.plan-card-app.current {
  border-color: rgba(14, 116, 109, .35);
  box-shadow: inset 0 0 0 1px rgba(14, 116, 109, .18);
}

.plan-card-app h2 {
  margin: 6px 0;
  color: #13231f;
}

.plan-card-app strong {
  display: block;
  color: var(--brand);
  font-size: 30px;
}

.plan-card-app p {
  color: #69756f;
}

@media (max-width: 980px) {
  .tool-controls,
  .settings-layout,
  .template-workspace,
  .account-dashboard,
  .plan-grid-app,
  .setting-row-card {
    grid-template-columns: 1fr;
  }

  .tool-card-full {
    min-height: auto;
  }

  .tool-summary-strip,
  .usage-grid {
    grid-template-columns: 1fr;
  }

  .app-page-head,
  body[data-view="tools"] .page-head,
  .account-hero-card,
  .message-template-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.app-html .group-row > span small.warning {
  color: #b42318;
}

.app-html .group-row > em {
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  color: var(--brand-dark, #0c5a55);
  flex-shrink: 0;
  padding: 2px 8px;
  background: rgba(14, 116, 109, .1);
  border-radius: 999px;
}

/* ---- Manager toolbar (Save selected groups button + hint) ---- */
.app-html .manager-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-html .manager-toolbar button {
  border: 0;
  background: var(--brand, #0e746d);
  color: #fff8ec;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .16s ease;
}

.app-html .manager-toolbar button:hover {
  background: var(--brand-dark, #0c5a55);
}

.app-html .manager-toolbar small {
  color: var(--muted, #69756f);
  font-size: 11px;
  font-weight: 600;
}

/* ============================================================
   v40: Permission row (Admin / Can create accounts / Cargo Access)
   - Inline checkboxes with 12px gap
   - User-form permission chips
   ============================================================ */
.app-html .permission-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(54, 70, 63, .12);
  border-radius: 10px;
  background: rgba(255, 253, 248, .72);
}

.app-html .permission-row > label {
  display: inline-flex;
  align-items: center;
  flex-direction: row;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #15231f);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.app-html .permission-row > label > input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  accent-color: var(--brand, #0e746d);
  cursor: pointer;
  margin: 0;
}

.app-html .permission-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.app-html .permission-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(54, 70, 63, .12);
  border-radius: 8px;
  background: rgba(255, 253, 248, .92);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}

.app-html .permission-chip:hover {
  border-color: rgba(14, 116, 109, .3);
  background: #fffdf8;
}

.app-html .permission-chip > input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  accent-color: var(--brand, #0e746d);
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.app-html .permission-chip > span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.app-html .permission-chip > span strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink, #15231f);
  word-break: break-word;
}

.app-html .permission-chip > span small {
  font-size: 10px;
  color: var(--muted, #69756f);
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  word-break: break-all;
}

/* ---- Personal Numbers card: import area + list ---- */
body[data-view="broadcast"] .contact-import {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(54, 70, 63, .12);
  background: var(--surface-2);
}

body[data-view="broadcast"] .contact-import label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body[data-view="broadcast"] .contact-import select {
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid rgba(54, 70, 63, .16);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  cursor: pointer;
}

body[data-view="broadcast"] .contact-import textarea {
  font-size: 12px;
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  min-height: 80px;
  padding: 10px;
  border: 1px solid rgba(54, 70, 63, .16);
  border-radius: 8px;
  background: #fff;
  resize: vertical;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  line-height: 1.5;
}

body[data-view="broadcast"] .inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

body[data-view="broadcast"] .inline-actions button {
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid rgba(14, 116, 109, .3);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease;
}

body[data-view="broadcast"] .inline-actions button:hover {
  background: var(--brand-dark);
}

body[data-view="broadcast"] .inline-actions button.outline-button {
  background: transparent;
  color: var(--ink);
  border-color: rgba(54, 70, 63, .16);
}

body[data-view="broadcast"] .inline-actions button.outline-button:hover {
  background: var(--surface-2);
  border-color: var(--brand);
  color: var(--brand-dark);
}

body[data-view="broadcast"] .contact-list {
  max-height: 200px;
}

body[data-view="broadcast"] .contact-list:empty::before {
  content: "No personal numbers yet. Paste phone numbers above and click Import.";
  display: block;
  padding: 14px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed rgba(54, 70, 63, .12);
  border-radius: 10px;
  margin: 14px 16px;
  line-height: 1.5;
}

/* ---- Template card: form + list ---- */
body[data-view="broadcast"] .template-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid rgba(54, 70, 63, .12);
}

body[data-view="broadcast"] .template-form .form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

body[data-view="broadcast"] .template-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body[data-view="broadcast"] .template-form input,
body[data-view="broadcast"] .template-form textarea {
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid rgba(54, 70, 63, .16);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.5;
}

body[data-view="broadcast"] .template-form textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}

body[data-view="broadcast"] .template-helper {
  font-size: 11px;
  color: var(--muted);
  background: #fff;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px dashed rgba(54, 70, 63, .12);
  line-height: 1.5;
  word-break: break-word;
}

body[data-view="broadcast"] .template-helper code {
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  font-size: 10px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(54, 70, 63, .08);
  color: var(--brand-dark);
}

body[data-view="broadcast"] #save-template {
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid rgba(14, 116, 109, .3);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
  min-height: 36px;
}

body[data-view="broadcast"] #save-template:hover {
  background: var(--brand-dark);
}

body[data-view="broadcast"] .template-list {
  max-height: 200px;
}

body[data-view="broadcast"] .template-list:empty::before {
  content: "No templates yet. Create one above to reuse in broadcasts.";
  display: block;
  padding: 14px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed rgba(54, 70, 63, .12);
  border-radius: 10px;
  margin: 14px 16px;
  line-height: 1.5;
}

body[data-view="broadcast"] .template-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(54, 70, 63, .12);
  border-radius: 10px;
  background: rgba(255, 253, 248, .92);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}

body[data-view="broadcast"] .template-item:hover {
  border-color: rgba(14, 116, 109, .3);
  background: #fffdf8;
}

body[data-view="broadcast"] .template-item strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}

body[data-view="broadcast"] .template-item small {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

body[data-view="broadcast"] .template-item span {
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-2);
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(54, 70, 63, .08);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60px;
  overflow: auto;
}

/* ---- Send Console card: make it stand out ---- */
body[data-view="broadcast"] .broadcast-console-card {
  border: 1px solid rgba(14, 116, 109, .25);
  background: linear-gradient(180deg, #fffdf8 0%, #fdf7e8 100%);
  box-shadow: 0 20px 50px rgba(14, 116, 109, .12);
}

body[data-view="broadcast"] .broadcast-console-card .card-head {
  background: linear-gradient(135deg, rgba(14, 116, 109, .14), transparent 56%), #fffdf8;
  border-bottom: 1px solid rgba(14, 116, 109, .18);
}

/* ---- Mode tabs: horizontal segmented control ---- */
body[data-view="broadcast"] .broadcast-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(14, 116, 109, .18);
  border-radius: 12px;
  background: rgba(14, 116, 109, .05);
}

body[data-view="broadcast"] .broadcast-mode-tabs label {
  display: grid;
  grid-template-columns: 18px 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  min-height: 0;
}

body[data-view="broadcast"] .broadcast-mode-tabs label:hover {
  background: rgba(255, 255, 255, .55);
}

body[data-view="broadcast"] .broadcast-mode-tabs label.active {
  background: #fff;
  border-color: rgba(14, 116, 109, .32);
  box-shadow: 0 4px 12px rgba(14, 116, 109, .1);
}

body[data-view="broadcast"] .broadcast-mode-tabs input {
  position: static;
  width: 16px;
  height: 16px;
  margin: 0;
  transform: none;
  grid-row: 1 / span 2;
  accent-color: var(--brand);
  cursor: pointer;
}

body[data-view="broadcast"] .broadcast-mode-tabs span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  grid-column: 2;
  grid-row: 1;
}

body[data-view="broadcast"] .broadcast-mode-tabs small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  grid-column: 2;
  grid-row: 2;
  text-transform: none;
  letter-spacing: 0;
}

/* ---- Broadcast form: cleaner spacing ---- */
body[data-view="broadcast"] .broadcast-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
}

body[data-view="broadcast"] .broadcast-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body[data-view="broadcast"] .broadcast-form input,
body[data-view="broadcast"] .broadcast-form select,
body[data-view="broadcast"] .broadcast-form textarea {
  font-size: 13px;
  padding: 9px 11px;
  border: 1px solid rgba(54, 70, 63, .16);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-family: inherit;
  line-height: 1.5;
}

body[data-view="broadcast"] .broadcast-form textarea {
  min-height: 130px;
  resize: vertical;
  font-family: inherit;
}

body[data-view="broadcast"] .broadcast-form .form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

body[data-view="broadcast"] .broadcast-form #media-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

body[data-view="broadcast"] .broadcast-form #media-row input[type="file"] {
  padding: 6px 8px;
  font-size: 12px;
  background: var(--surface-2);
}

/* ---- Preview panel: compact, single row ---- */
body[data-view="broadcast"] .broadcast-preview-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed rgba(14, 116, 109, .25);
  border-radius: 12px;
  background: #fff;
}

body[data-view="broadcast"] .broadcast-preview-panel small {
  font-size: 10px;
  color: var(--brand-dark);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

body[data-view="broadcast"] .broadcast-preview-panel strong {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}

body[data-view="broadcast"] .broadcast-preview-panel p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body[data-view="broadcast"] .broadcast-preview-panel > span {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-dark);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---- Strategy grid: 2 columns of strategy inputs ---- */
body[data-view="broadcast"] .strategy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(14, 116, 109, .04);
  border: 1px solid rgba(14, 116, 109, .1);
}

body[data-view="broadcast"] .strategy-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

body[data-view="broadcast"] .strategy-grid input,
body[data-view="broadcast"] .strategy-grid select {
  font-size: 12px;
  padding: 6px 9px;
  border: 1px solid rgba(54, 70, 63, .16);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-family: inherit;
}

body[data-view="broadcast"] .strategy-grid .schedule-field input {
  color: var(--ink);
}

body[data-view="broadcast"] .safety-copy {
  font-size: 11px;
  color: var(--muted);
  background: rgba(14, 116, 109, .04);
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 3px solid var(--brand);
  line-height: 1.5;
  margin: 0;
  word-break: break-word;
}

body[data-view="broadcast"] #broadcast-send {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
  margin-top: 4px;
  box-shadow: 0 8px 18px rgba(14, 116, 109, .25);
  transition: transform .15s ease, box-shadow .15s ease;
}

body[data-view="broadcast"] #broadcast-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(14, 116, 109, .35);
}

body[data-view="broadcast"] #broadcast-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---- Job History card: full-width, polished ---- */
body[data-view="broadcast"] .jobs-card {
  margin-top: 4px;
  border: 1px solid rgba(54, 70, 63, .12);
  background: rgba(255, 253, 248, .92);
}

body[data-view="broadcast"] .jobs-card .card-head {
  background: var(--surface-2);
  border-bottom: 1px solid rgba(54, 70, 63, .12);
}

body[data-view="broadcast"] .jobs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 18px;
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
}

body[data-view="broadcast"] .jobs:empty::before {
  content: "No jobs yet. Create a broadcast above to see it here.";
  display: block;
  padding: 24px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed rgba(54, 70, 63, .12);
  border-radius: 10px;
  line-height: 1.5;
}

body[data-view="broadcast"] .job {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid rgba(54, 70, 63, .12);
  border-radius: 12px;
  background: #fff;
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

body[data-view="broadcast"] .job:hover {
  border-color: rgba(14, 116, 109, .3);
  box-shadow: 0 8px 18px rgba(14, 116, 109, .08);
}

body[data-view="broadcast"] .job > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

body[data-view="broadcast"] .job > header strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}

body[data-view="broadcast"] .job > header .status {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body[data-view="broadcast"] .job > p {
  margin: 0;
  font-size: 12px;
  color: var(--ink);
  word-break: break-word;
  white-space: pre-wrap;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(54, 70, 63, .08);
}

body[data-view="broadcast"] .job > small {
  font-size: 11px;
  color: var(--muted);
  font-family: "SF Mono", "Consolas", "Menlo", monospace;
  word-break: break-word;
}

/* ---- Responsive: tablet ---- */
@media (max-width: 1100px) {
  body[data-view="broadcast"] .broadcast-studio {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* ---- Responsive: phone ---- */
@media (max-width: 760px) {
  body[data-view="broadcast"] .page-wrap {
    padding: 14px 14px 24px;
  }

  body[data-view="broadcast"] .broadcast-studio {
    grid-template-columns: 1fr;
  }

  body[data-view="broadcast"] .broadcast-console-card {
    position: static;
    max-height: none;
  }

  body[data-view="broadcast"] .template-form .form-row,
  body[data-view="broadcast"] .broadcast-form .form-row,
  body[data-view="broadcast"] .strategy-grid {
    grid-template-columns: 1fr;
  }

  body[data-view="broadcast"] .broadcast-preview-panel {
    grid-template-columns: 1fr;
  }

  body[data-view="broadcast"] .broadcast-preview-panel > span {
    justify-self: flex-start;
  }
}

/* ============================================================ */
/*  Auth/landing pages — site header, login card, register card  */
/* ============================================================ */

.site-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 32px;
}
.site-topline .lang-toggle {
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
}
.site-topline .lang-toggle button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.site-topline .lang-toggle button.active {
  background: rgba(14, 116, 109, 0.1);
  color: var(--brand);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--ink);
}
.site-brand > span:first-child {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
}
.site-brand strong {
  font-size: 18px;
  letter-spacing: -0.02em;
  display: block;
  line-height: 1.1;
}
.site-brand small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.site-menu {
  display: flex;
  gap: 28px;
}
.site-menu a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}
.site-menu a:hover { color: var(--brand); }

.site-cta {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  transition: background 0.2s;
}
.site-cta:hover { background: var(--brand-dark); }

.auth-template-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
  max-width: 1100px;
  margin: 60px auto;
  padding: 0 32px;
  min-height: 500px;
}
.auth-template-copy small {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  background: rgba(14, 116, 109, 0.08);
  padding: 4px 12px;
  border-radius: 100px;
  margin-bottom: 16px;
}
.auth-template-copy h1 {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 14px;
  color: var(--ink);
}
.auth-template-copy p {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 420px;
}

.login-card-pro {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.08);
  max-width: 440px;
  width: 100%;
  justify-self: end;
}
.login-card-title { margin-bottom: 24px; }
.login-card-title small {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
}
.login-card-title h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-form label > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.login-form input {
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.login-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 116, 109, 0.1);
}
.login-form button[type="submit"] {
  margin-top: 8px;
  padding: 13px 20px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.login-form button[type="submit"]:hover { background: var(--brand-dark); }
.login-form button[type="submit"]:active { transform: translateY(1px); }

.login-note {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.login-note a {
  color: var(--brand);
  font-weight: 600;
}

.site-footer.template-footer {
  margin-top: 60px;
  padding: 32px 24px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}
.site-footer.template-footer > div:first-child strong {
  font-size: 16px;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}
.site-footer.template-footer > div:first-child p {
  font-size: 12px;
  color: var(--muted);
  max-width: 480px;
  line-height: 1.5;
}
.site-footer.template-footer > nav {
  display: flex;
  gap: 20px;
}
.site-footer.template-footer > nav a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.site-footer.template-footer > nav a:hover { color: var(--brand); }

@media (max-width: 900px) {
  .site-menu { display: none; }
  .site-header { padding: 12px 20px; }
  .site-topline { padding: 6px 20px; }
  .auth-template-section {
    grid-template-columns: 1fr;
    gap: 32px;
    margin: 32px auto;
    padding: 0 20px;
  }
  .auth-template-copy h1 { font-size: 28px; }
  .login-card-pro { padding: 32px 24px; justify-self: stretch; max-width: none; }
  .site-footer.template-footer {
    flex-direction: column;
    text-align: center;
    margin: 40px 20px 0;
  }
}

/* ============================================================
   v23 — License Key Management + Translation + Profile Modal
   ============================================================ */

/* License Key Admin Card */
.app-html .license-keys-card { grid-column: 1 / -1; }

.app-html .license-gen-form {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.app-html .license-gen-form .form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.app-html .license-gen-form .form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.app-html .license-gen-form .form-row input,
.app-html .license-gen-form .form-row select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  min-width: 140px;
}
.app-html .license-gen-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.app-html .license-gen-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(14,116,109,.3); }
.app-html .license-gen-btn:disabled { opacity: .6; cursor: default; transform: none; }

.app-html .license-filter-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  align-items: center;
}
.app-html .license-filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.app-html .license-filter-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.app-html .license-export-btn {
  margin-left: auto;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.app-html .license-export-btn:hover { background: var(--surface-2); }

/* License Key List */
.app-html .license-key-list {
  max-height: 480px;
  overflow-y: auto;
  padding: 8px;
}
.app-html .license-key-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
  background: var(--surface);
  transition: all .2s;
}
.app-html .license-key-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.app-html .license-key-row.used { opacity: .7; }
.app-html .lk-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.app-html .lk-code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  letter-spacing: 1px;
  color: var(--ink);
}
.app-html .lk-type { font-size: 11px; color: var(--muted); }
.app-html .lk-status { font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.app-html .lk-status.status-unused { background: rgba(20,184,112,.12); color: #0a8a55; }
.app-html .lk-status.status-used { background: rgba(100,116,139,.12); color: var(--muted); }
.app-html .lk-meta { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.app-html .lk-meta small { font-size: 10px; color: var(--muted); }
.app-html .lk-delete { font-size: 11px; padding: 4px 10px; color: #b14b4b; border-color: rgba(177,75,75,.3); }

/* Profile Modal — Card Key Activation */
.app-html .profile-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.app-html .profile-modal.active { opacity: 1; visibility: visible; }
.app-html .profile-card {
  background: var(--surface);
  border-radius: 16px;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2);
  transform: translateY(20px);
  transition: transform .2s;
}
.app-html .profile-modal.active .profile-card { transform: translateY(0); }
.app-html .profile-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.app-html .profile-card header h2 { font-size: 22px; font-weight: 800; margin: 4px 0 0; }
.app-html .profile-card header small { font-size: 11px; color: var(--muted); letter-spacing: 1px; font-weight: 600; }
.app-html .profile-card header button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 14px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}
.app-html .profile-card dl { margin: 0 0 20px; }
.app-html .profile-card dl div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.app-html .profile-card dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.app-html .profile-card dd { font-size: 13px; color: var(--ink); font-weight: 600; text-align: right; }
.app-html .pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.app-html .price-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.app-html .price-card small { font-size: 11px; color: var(--muted); }
.app-html .price-card strong { font-size: 20px; color: var(--brand); }
.app-html .price-card span { font-size: 11px; color: var(--muted); }
.app-html .price-card button {
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.app-html .price-card button:hover { background: var(--brand); color: #fff; }
.app-html .order-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}
.app-html .order-list span { font-size: 12px; color: var(--muted); }

/* Card Key Activation Section */
.app-html .card-key-section {
  border: 1px solid rgba(14,116,109,.2);
  border-radius: 12px;
  padding: 16px;
  background: rgba(14,116,109,.04);
}
.app-html .card-key-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-dark);
  margin: 0 0 6px;
}
.app-html .card-key-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}
.app-html .card-key-input-row {
  display: flex;
  gap: 8px;
}
.app-html .card-key-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  letter-spacing: 1px;
}
.app-html .card-key-input-row input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14,116,109,.1);
}
.app-html .card-key-activate-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.app-html .card-key-activate-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(14,116,109,.3); }
.app-html .card-key-activate-btn:disabled { opacity: .6; cursor: default; transform: none; }

/* Translation Feature */
.app-html .message-translate-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.app-html .translate-btn {
  border: 1px solid rgba(14,116,109,.2);
  border-radius: 6px;
  padding: 2px 10px;
  background: rgba(14,116,109,.04);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.app-html .translate-btn:hover { background: rgba(14,116,109,.1); }
.app-html .translate-btn:disabled { opacity: .5; cursor: default; }
.app-html .translation-display {
  display: none;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border-left: 2px solid var(--brand);
  background: rgba(14,116,109,.04);
  border-radius: 0 6px 6px 0;
  margin-top: 4px;
  width: 100%;
}
.app-html .translation-display.translation-shown { display: block; }

/* Admin grid update — accommodate new card */
.app-html .admin-grid { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.4fr); }
@media (max-width: 960px) {
  .app-html .admin-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Email Campaign — Admin
   ============================================================ */
.app-html .email-campaign-card { grid-column: 1 / -1; }
.app-html .campaign-compose { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.app-html .campaign-compose .form-row { display: flex; flex-direction: column; gap: 6px; }
.app-html .campaign-compose label { font-size: 13px; font-weight: 600; color: var(--text, #0f172a); }
.app-html .campaign-compose select,
.app-html .campaign-compose input,
.app-html .campaign-compose textarea {
  padding: 10px 12px; border: 1px solid var(--border, #e2e8f0); border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none; transition: border-color .2s;
  background: var(--bg, #f8fafc); color: var(--text, #0f172a);
}
.app-html .campaign-compose select:focus,
.app-html .campaign-compose input:focus,
.app-html .campaign-compose textarea:focus { border-color: var(--brand, #25D366); }
.app-html .campaign-compose textarea { resize: vertical; min-height: 100px; }
.app-html .campaign-send-btn {
  align-self: flex-start; padding: 11px 24px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand, #25D366), var(--brand-dark, #128C7E));
  color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; transition: all .2s;
}
.app-html .campaign-send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(37,211,102,.3); }
.app-html .campaign-send-btn:disabled { opacity: .6; cursor: not-allowed; }

.app-html .campaign-history { margin-bottom: 20px; }
.app-html .campaign-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--border, #e2e8f0); border-radius: 10px;
  margin-bottom: 8px; background: var(--bg, #f8fafc);
}
.app-html .campaign-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-html .campaign-subject { font-size: 14px; font-weight: 600; color: var(--text, #0f172a); }
.app-html .campaign-meta { font-size: 12px; color: var(--text-muted, #64748b); }
.app-html .campaign-status { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 100px; text-transform: uppercase; }
.app-html .campaign-status.status-completed { background: #f0fdf4; color: #16a34a; }
.app-html .campaign-empty { padding: 20px; text-align: center; color: var(--text-muted, #64748b); font-size: 13px; }

.app-html .campaign-logs-title { font-size: 13px; font-weight: 700; color: var(--text, #0f172a); margin-bottom: 10px; padding-top: 12px; border-top: 1px solid var(--border, #e2e8f0); }
.app-html .email-logs-list { max-height: 320px; overflow-y: auto; }
.app-html .email-log-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border, #e2e8f0);
}
.app-html .email-log-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; overflow: hidden; }
.app-html .email-log-to { font-size: 13px; font-weight: 600; color: var(--text, #0f172a); }
.app-html .email-log-subject { font-size: 12px; color: var(--text-muted, #64748b); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-html .email-log-meta { font-size: 11px; color: var(--text-light, #94a3b8); }
.app-html .email-log-status { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 100px; text-transform: uppercase; flex-shrink: 0; }
.app-html .email-log-status.status-sent { background: #f0fdf4; color: #16a34a; }
.app-html .email-log-status.status-failed { background: #fef2f2; color: #ef4444; }

/* ===== Team Management ===== */
.app-html .team-section {
  margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border, #e2e8f0);
}
.app-html .team-section h3 { font-size: 16px; font-weight: 700; color: var(--text, #0f172a); margin-bottom: 6px; }
.app-html .team-seats-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #bbf7d0; border-radius: 12px; margin: 12px 0;
}
.app-html .team-seats-info { font-size: 14px; color: var(--text, #0f172a); font-weight: 500; }
.app-html .team-seats-info .seats-used { font-weight: 800; color: #128C7E; }
.app-html .team-seats-info .seats-available { font-weight: 700; color: #16a34a; }
.app-html .team-seats-info .seats-total { font-weight: 600; color: var(--text-muted, #64748b); }
.app-html .team-seats-purchase { display: flex; align-items: center; gap: 8px; }
.app-html .seats-qty-input {
  width: 56px; padding: 6px 8px; border: 1px solid var(--border, #e2e8f0); border-radius: 8px;
  font-size: 13px; text-align: center; background: var(--bg, #fff); color: var(--text, #0f172a);
}
.app-html .seats-purchase-btn {
  padding: 7px 14px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
  background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; cursor: pointer;
  transition: opacity .2s, transform .15s;
}
.app-html .seats-purchase-btn:hover { opacity: .9; transform: translateY(-1px); }
.app-html .team-add-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0;
}
.app-html .team-add-form input {
  padding: 8px 12px; border: 1px solid var(--border, #e2e8f0); border-radius: 8px;
  font-size: 13px; background: var(--bg, #fff); color: var(--text, #0f172a);
  transition: border-color .2s;
}
.app-html .team-add-form input:focus { border-color: #25D366; outline: none; box-shadow: 0 0 0 3px rgba(37,211,102,.1); }
.app-html .team-add-form input::placeholder { color: var(--text-light, #94a3b8); }
.app-html .team-add-btn {
  grid-column: 1 / -1; padding: 10px; border: none; border-radius: 10px; font-size: 14px; font-weight: 700;
  background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; cursor: pointer;
  transition: opacity .2s, transform .15s;
}
.app-html .team-add-btn:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.app-html .team-add-btn:disabled { opacity: .5; cursor: not-allowed; }
.app-html .team-member-list { max-height: 280px; overflow-y: auto; }
.app-html .team-member-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px; border: 1px solid var(--border, #e2e8f0); border-radius: 10px;
  margin-bottom: 8px; background: var(--bg, #f8fafc); transition: border-color .2s;
}
.app-html .team-member-item:hover { border-color: #25D366; }
.app-html .team-member-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-html .team-member-info strong { font-size: 14px; color: var(--text, #0f172a); }
.app-html .team-member-info span { font-size: 12px; color: var(--text-muted, #64748b); }
.app-html .team-member-remove {
  padding: 5px 12px; border: 1px solid #fecaca; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: #fef2f2; color: #ef4444; cursor: pointer; transition: all .2s; flex-shrink: 0;
}
.app-html .team-member-remove:hover { background: #fee2e2; border-color: #ef4444; }
.app-html .team-empty { padding: 16px; text-align: center; color: var(--text-muted, #64748b); font-size: 13px; }

/* ============================================================
   v27 — RehobothCargo Info Panel (right column in chat view)
   ============================================================ */

/* Three-column layout when rh panel is visible */
.app-html .chat-page.rh-visible {
  grid-template-columns: 280px minmax(0, 1fr) 340px !important;
}

/* The panel itself */
.rh-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  background: var(--surface, #fff);
  border-left: 1px solid var(--line, #e2e8f0);
  overflow: hidden;
}
.rh-panel.is-hidden { display: none; }

.rh-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  background: var(--surface, #fff);
  flex-shrink: 0;
}
.rh-panel-head h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #111;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rh-panel-head h2::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25D366;
}
.rh-panel-close {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-muted, #64748b);
}
.rh-panel-close:hover { background: #f1f5f9; color: #111; }

/* User card at top of panel */
.rh-user-card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  flex-shrink: 0;
}
.rh-user-empty {
  text-align: center;
  color: var(--text-muted, #64748b);
  font-size: 13px;
  padding: 12px 0;
}
.rh-user-found {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rh-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #475569;
  flex-shrink: 0;
  overflow: hidden;
}
.rh-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rh-user-meta {
  flex: 1;
  min-width: 0;
}
.rh-user-name {
  font-size: 14px;
  font-weight: 700;
  color: #111;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rh-user-sub {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rh-user-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #ecfdf5;
  color: #059669;
  margin-top: 2px;
}
.rh-user-badge.inactive { background: #fef2f2; color: #ef4444; }
.rh-user-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.rh-user-actions button {
  padding: 4px 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: all .15s;
}
.rh-user-actions button:hover { background: #f8fafc; border-color: #cbd5e1; }
.rh-user-actions button.rh-btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.rh-user-actions button.rh-btn-primary:hover { background: #1d4ed8; }

/* Tabs (v39: icon-first layout with small label underneath) */
.rh-tabs {
  display: flex;
  border-bottom: 1px solid var(--line, #e2e8f0);
  flex-shrink: 0;
  overflow-x: auto;
  padding: 4px 2px 0;
  gap: 2px;
}
.rh-tab {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 4px 8px;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  border-bottom: 2px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
  border-radius: 6px 6px 0 0;
  position: relative;
}
.rh-tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}
.rh-tab .rh-tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.rh-tab:hover {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.06);
}
.rh-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}
.rh-tab.active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: #2563eb;
  border-radius: 2px 2px 0 0;
}
/* Hide labels on very narrow panels (icons only) */
.rh-panel[data-narrow="1"] .rh-tab-label { display: none; }
.rh-panel[data-narrow="1"] .rh-tab { padding: 8px 4px; }

/* Tab body (scrollable content) */
.rh-tab-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 10px;
}

/* Empty / loading states */
.rh-empty {
  text-align: center;
  color: var(--text-muted, #64748b);
  font-size: 13px;
  padding: 24px 12px;
}
.rh-loading {
  text-align: center;
  color: var(--text-muted, #64748b);
  font-size: 13px;
  padding: 24px 12px;
}
.rh-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: rh-spin .6s linear infinite;
  margin-left: 6px;
  vertical-align: middle;
}
@keyframes rh-spin { to { transform: rotate(360deg); } }

/* Data cards inside tab body */
.rh-data-card {
  background: #f8fafc;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  position: relative;
}
.rh-data-card:hover { border-color: #cbd5e1; }
.rh-data-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.rh-data-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #111;
}
.rh-data-card-status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.rh-data-card-status.paid { background: #ecfdf5; color: #059669; }
.rh-data-card-status.unpaid { background: #fef2f2; color: #ef4444; }
.rh-data-card-status.shipped { background: #eff6ff; color: #2563eb; }
.rh-data-card-status.pending { background: #fefce8; color: #ca8a04; }
.rh-data-card-status.delivered { background: #f0fdf4; color: #16a34a; }
.rh-data-card-status.open { background: #eff6ff; color: #2563eb; }
.rh-data-card-status.closed { background: #f1f5f9; color: #64748b; }
.rh-data-card-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}
.rh-data-card-row .label { color: var(--text-muted, #64748b); flex-shrink: 0; }
.rh-data-card-row .value { color: #334155; text-align: right; word-break: break-all; }
.rh-data-card-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line, #e2e8f0);
}
.rh-send-btn {
  padding: 3px 8px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.rh-send-btn:hover { background: #2563eb; color: #fff; border-color: #2563eb; }
.rh-send-btn svg { width: 12px; height: 12px; }

/* Info tab special styles */
.rh-info-section {
  margin-bottom: 12px;
}
.rh-info-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted, #64748b);
  margin-bottom: 4px;
}
.rh-info-addr {
  background: #f8fafc;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #334155;
  position: relative;
}
.rh-info-addr .rh-send-btn {
  position: absolute;
  top: 6px;
  right: 6px;
}
.rh-info-mark {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  margin-top: 4px;
}

/* Create user form (when phone not found) */
.rh-create-form {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
}
.rh-create-form h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  color: #111;
}
.rh-create-form .rh-form-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
}
.rh-create-form label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}
.rh-create-form input {
  padding: 6px 8px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.rh-create-form input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .1);
}
.rh-create-hint {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin: 0 0 10px;
  font-style: italic;
}
.rh-create-foot {
  font-size: 10.5px;
  color: var(--text-muted, #64748b);
  margin: 8px 0 0;
  line-height: 1.4;
}
.rh-form-row-inline {
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
}
.rh-form-row-inline label {
  flex: 0 0 100px;
  margin: 0;
}
.rh-form-row-inline input {
  flex: 1 1 auto;
}
.rh-form-row-inline button {
  flex: 0 0 auto;
}
.rh-btn-secondary {
  padding: 6px 10px;
  border: 1px solid var(--line, #e2e8f0);
  background: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all .15s;
}
.rh-btn-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.rh-form-avatar-row {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}
.rh-form-avatar-row label {
  flex: 0 0 60px;
  margin: 0;
}
.rh-form-avatar-preview {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rh-form-avatar-preview img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line, #e2e8f0);
}
.rh-form-avatar-empty {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  font-style: italic;
}

/* v39: Login Info modal */
.rh-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: rh-fade-in .15s ease-out;
}
@keyframes rh-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.rh-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  animation: rh-modal-in .18s ease-out;
}
@keyframes rh-modal-in {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.rh-modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.rh-modal-head h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}
.rh-modal-close {
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.rh-modal-close:hover { background: #f1f5f9; color: #0f172a; }
.rh-modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rh-modal-hint {
  font-size: 11.5px;
  color: var(--text-muted, #64748b);
  margin: 0 0 4px;
  padding: 8px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  border-left: 3px solid #2563eb;
}
.rh-modal-body .rh-form-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
}
.rh-modal-body label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
}
.rh-modal-body input {
  padding: 6px 8px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}
.rh-modal-body input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .1);
}
.rh-modal-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line, #e2e8f0);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.rh-modal-foot .rh-btn-primary {
  padding: 8px 18px;
  border: 0;
  background: #2563eb;
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.rh-modal-foot .rh-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.rh-modal-foot .rh-btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.rh-form-preview {
  background: #f8fafc;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: #334155;
  margin-top: 4px;
}
.rh-form-preview summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin-bottom: 6px;
  user-select: none;
}
.rh-form-preview summary::marker { color: #2563eb; }
.rh-form-preview pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'SFMono-Regular', 'Menlo', 'Consolas', monospace;
  font-size: 11px;
  line-height: 1.5;
  color: #0f172a;
}
#rh-li-fetch-token {
  margin-top: 4px;
  font-size: 11px;
  padding: 4px 8px;
}

/* v36: RH Panel 永久第 4 栏 (grid 内), 关闭时 display:none 不占空间 */
@media (max-width: 1100px) {
  .app-html .chat-page {
    /* JS 控制 3 栏, 这里给 fallback */
  }
  .rh-panel.is-hidden { display: none !important; }
}
@media (max-width: 720px) {
  /* 移动端 RH 改为浮层 (在 4 栏太挤) */
  .rh-panel:not(.is-hidden) {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    z-index: 50;
    box-shadow: -4px 0 12px rgba(0,0,0,.08);
  }
}

/* ============================================================
   v28: Conversation custom name (per-chat display name)
   ============================================================ */
.thread-actions .thread-icon-btn#thread-edit-name {
  color: #64748b;
  transition: color .15s ease;
}
.thread-actions .thread-icon-btn#thread-edit-name:hover {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}
.thread-head.has-custom-name #thread-name {
  color: #2563eb;
}
.thread-head.has-custom-name #thread-name::after {
  content: '★';
  margin-left: 6px;
  font-size: 12px;
  color: #f59e0b;
}
.conversation.has-custom-name .conversation-copy strong {
  color: #2563eb;
}
.custom-name-tag {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  color: #f59e0b;
  cursor: help;
}
.conversation.has-custom-name .conversation-copy {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.conversation.has-custom-name .conversation-copy small,
.conversation.has-custom-name .conversation-copy p {
  flex: 1 0 100%;
  margin-top: 2px;
}

/* v28: Address blocks in RH info tab (sea/air shipping) */
.rh-addr-text {
  font-size: 12.5px;
  line-height: 1.45;
  color: #1e293b;
  word-break: break-word;
  margin-bottom: 4px;
  white-space: pre-wrap;
}
.rh-addr-meta {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 6px;
}

/* -------------------------------------------------------------- */
/* v29: Beautified filter bar + message templates                  */
/* -------------------------------------------------------------- */

.filter-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  min-width: 0;
}
.filter-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 0;
}
.filter-row-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.filter-chip {
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.filter-chip:hover { background: var(--surface-2); color: var(--ink); }
.filter-chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.filter-chip-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.filter-chip-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56px;
}
.filter-chip-new {
  width: 26px;
  height: 26px;
  padding: 0;
  justify-content: center;
  flex-shrink: 0;
}
.filter-list-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 0 6px 0 8px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 90px;
  max-width: 130px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-list-wrap:hover { border-color: var(--ink); }
.filter-list-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}
.filter-list-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}
.filter-list-select {
  border: 0;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
  height: 24px;
  outline: none;
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
  text-overflow: ellipsis;
  overflow: hidden;
  padding: 0 2px;
}
.filter-search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 26px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0 8px 0 6px;
  flex: 1 1 auto;
  min-width: 100px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-search-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}
.filter-search-icon {
  width: 13px;
  height: 13px;
  color: var(--muted);
  flex-shrink: 0;
}
.filter-search-input {
  border: 0;
  background: transparent;
  outline: none;
  height: 26px;
  font-size: 11.5px;
  color: var(--ink);
  padding: 0 4px;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}
.filter-search-input::placeholder { color: #9ca3af; }
.filter-search-input::-webkit-search-cancel-button { display: none; }
.filter-search-clear {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.filter-search-clear:hover { color: var(--ink); }

/* Message templates panel (right side, similar to rh-panel) */
.template-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface);
  width: 340px;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  z-index: 2;
}
.template-panel.is-hidden { display: none; }
.template-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.template-panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.template-panel-close {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 4px;
}
.template-panel-close:hover { background: var(--surface-2); color: var(--ink); }
.template-panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 14px 16px;
}
.template-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 6px;
}
.template-new-btn {
  height: 28px;
  padding: 0 12px;
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.template-new-btn:hover { background: #0a0a0a; }
.template-count {
  font-size: 11px;
  color: var(--muted);
}

.template-editor {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.template-editor.is-hidden { display: none; }
.template-editor-row {
  margin-bottom: 8px;
}
.template-editor-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.template-editor-row input[type="text"],
.template-editor-row input[type="url"],
.template-editor-row textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.template-editor-row textarea {
  resize: vertical;
  min-height: 70px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}
.template-editor-row input:focus,
.template-editor-row textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}
.template-tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.template-tag-hint {
  font-size: 11px;
  color: var(--muted);
  margin-right: 4px;
}
.template-tag-btn {
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}
.template-tag-btn:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.template-media-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.template-media-row input[type="file"] {
  font-size: 11px;
  color: var(--muted);
}
.template-media-row input[type="url"] {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  color: var(--ink);
  outline: none;
}
.template-media-preview {
  min-height: 4px;
  margin-top: 4px;
}
.template-media-preview img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.template-preview {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
}
.template-preview-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  font-weight: 600;
}
.template-preview-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}
.template-editor-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
}
.template-cancel-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.template-cancel-btn:hover { background: var(--surface-2); }
.template-save-btn {
  height: 28px;
  padding: 0 14px;
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.template-save-btn:hover { background: #0a0a0a; }

.template-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.message-template-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.message-template-card:hover {
  border-color: var(--ink);
  background: var(--surface-2);
}
.message-template-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 6px;
}
.message-template-head strong {
  font-size: 12.5px;
  color: var(--ink);
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-template-actions {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}
.message-template-actions button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.message-template-actions button:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.message-template-actions .message-template-delete:hover { background: #b91c1c; border-color: #b91c1c; }
.message-template-body {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 4px 0;
}
.message-template-labels {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  font-style: italic;
}
.template-media-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
}

/* Composer: templates button */
.composer-template-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.composer-template-btn:hover { background: var(--surface-2); color: var(--ink); }
.composer-template-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.composer-template-btn svg { width: 18px; height: 18px; }

/* Composer attach thumb (for templates) */
.composer-attach-thumb {
  position: relative;
  display: inline-block;
  margin: 4px 0;
}
.composer-attach-thumb img {
  max-height: 80px;
  max-width: 120px;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
}
.composer-attach-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: #1f2937;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

/* Toast */
.app-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
}
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Make chat-page handle template-panel like rh-panel */
body[data-view="chat"] .chat-page.template-panel-visible {
  grid-template-columns: 280px minmax(0,1fr) 340px;
}

/* Responsive: hide template panel on small screens */
@media (max-width: 1100px) {
  .template-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: -8px 0 24px rgba(0,0,0,0.1);
  }
  .filter-search-wrap { min-width: 140px; flex-basis: 180px; }
}

/* When template panel is open, extend grid to 3 columns */
body[data-view="chat"] .chat-page:has(.template-panel:not(.is-hidden)) {
  grid-template-columns: 340px minmax(0, 1fr) 340px !important;
}
/* If both RH panel and template panel are open, stack them differently via fallback */
body[data-view="chat"] .chat-page.rh-visible:has(.template-panel:not(.is-hidden)) {
  grid-template-columns: 340px minmax(0, 1fr) 340px 340px !important;
}

/* ============================================================
   v30 — Admin Tab Navigation
   ============================================================ */
.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 0 0 12px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
  transition: all 0.15s;
  position: relative;
  bottom: -2px;
  border-bottom: 2px solid transparent;
}
.admin-tab:hover { color: var(--ink); background: var(--surface-2); }
.admin-tab.active {
  color: var(--rail-active);
  border-bottom-color: var(--rail-active);
  background: rgba(20, 184, 112, 0.06);
}
.admin-tab svg { flex-shrink: 0; }

.admin-tab-content { animation: fadeIn 0.2s ease; }
.admin-tab-content.is-hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.admin-grid-two {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 960px) {
  .admin-grid-two { grid-template-columns: 1fr; }
}

/* Translation settings in user center */
.translation-settings-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.translation-settings-section h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink, #0f172a);
}
.translation-setting-row {
  display: flex;
  gap: 16px;
  margin: 12px 0;
  flex-wrap: wrap;
}
.translation-setting-row label {
  flex: 1;
  min-width: 200px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #0f172a);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.translation-setting-row select {
  height: 34px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  background: #fff;
  color: var(--ink, #0f172a);
  outline: 0;
  cursor: pointer;
}

/* ============================================================
   v35 — Resizable Layout System
   仅新增布局容器与拖拽交互，不修改原有业务DOM/色值/接口
   ============================================================ */

/* --- 1. Filter Column: 垂直铺满, 标题固定, 列表 flex:1 --- */
.app-html body[data-view="chat"] .filter-column {
  height: 100% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}
.app-html body[data-view="chat"] .filter-section {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px;
}
.app-html body[data-view="chat"] .filter-header {
  flex-shrink: 0;
}
.app-html body[data-view="chat"] #accounts {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

/* --- 2. Resize Handle 视觉 --- */
.rz-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 40;
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.rz-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  width: 2px;
  height: 100%;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 1px;
  transition: background 0.15s ease, width 0.15s ease;
}
.rz-handle:hover::before,
.rz-handle.dragging::before {
  background: rgba(37, 99, 235, 0.7);
  width: 3px;
}
.rz-handle:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* --- 3. 容器 position:relative 供 handle 定位 --- */
.app-shell { position: relative; }
.chat-page { position: relative; }
.broadcast-studio { position: relative; }
.admin-grid-two { position: relative; }

/* --- 4. 拖拽中禁用文字选中和指针事件 --- */
body.rz-dragging {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: col-resize !important;
}
body.rz-dragging * {
  pointer-events: none !important;
}
body.rz-dragging .rz-handle {
  pointer-events: auto !important;
}

/* --- 5. 各面板滚动区域独立隔离 --- */
.app-html body[data-view="chat"] .list-column {
  overflow: hidden;
}
.app-html body[data-view="chat"] .conversation-list {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.app-html body[data-view="chat"] .messages {
  overflow-y: auto;
  min-height: 0;
}
.app-html body[data-view="chat"] .rh-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-html body[data-view="chat"] .rh-tab-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.app-html body[data-view="chat"] .template-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-html body[data-view="chat"] .template-panel-body {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.translation-setting-row select:focus { border-color: var(--rail-active, #14b870); }

/* ============================================================
   v36: 4 栏布局 — RH Panel 永久第 4 栏 + Templates composer dropdown + Modal
   ============================================================ */

/* --- 1. RH Panel 永久第 4 栏 --- */
.app-html .chat-page {
  position: relative;
}
.app-html .chat-page > .rh-panel {
  width: 340px;
  min-width: 0;
  flex-shrink: 0;
  align-self: stretch;
  height: 100%;
  position: relative;     /* v36: 覆盖之前 fixed */
}
.app-html .chat-page > .rh-panel.is-hidden { display: none !important; }

/* --- 2. composer 模板气泡下拉面板 --- */
.composer-template-dropdown {
  position: fixed;       /* JS 会动态算 top/left, 浮动避免父链 overflow 裁切 */
  z-index: 9999;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  font-size: 13px;
  min-width: 320px;
}
.composer-template-dropdown .ctpl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 320px;
  padding-right: 2px;
}
.composer-template-dropdown .ctpl-item {
  padding: 8px 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  background: var(--surface, #fff);
}
.composer-template-dropdown .ctpl-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.composer-template-dropdown .ctpl-item-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.composer-template-dropdown .ctpl-item-head strong {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.composer-template-dropdown .ctpl-media-badge { font-size: 12px; }
.composer-template-dropdown .ctpl-item-del {
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #94a3b8;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
}
.composer-template-dropdown .ctpl-item-del:hover { background: #fee2e2; color: #dc2626; }
.composer-template-dropdown .ctpl-item-body {
  font-size: 12px;
  color: #475569;
  line-height: 1.45;
  max-height: 60px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.composer-template-dropdown .ctpl-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  padding: 16px 8px;
  margin: 0;
}
.composer-template-dropdown .ctpl-divider {
  height: 1px;
  background: var(--line, #e2e8f0);
  margin: 4px 2px;
}
.composer-template-dropdown .ctpl-new-btn {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #14b870, #0f9d5d);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease, transform .15s ease;
}
.composer-template-dropdown .ctpl-new-btn:hover { filter: brightness(1.05); }
.composer-template-dropdown .ctpl-new-btn:active { transform: scale(0.98); }

/* --- 3. 中央 Modal 弹窗 (新增模板) --- */
.tpl-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tplModalFade .18s ease;
}
.tpl-modal-mask[hidden] { display: none !important; }
.tpl-modal {
  width: min(520px, 92vw);
  max-height: 86vh;
  background: var(--surface, #fff);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.32);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tplModalPop .22s cubic-bezier(0.16, 1, 0.3, 1);
}
.tpl-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}
.tpl-modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
.tpl-modal-close {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  border-radius: 6px;
}
.tpl-modal-close:hover { background: #f1f5f9; color: #0f172a; }
.tpl-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.tpl-modal-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-modal-row label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tpl-modal-row input,
.tpl-modal-row textarea {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
  outline: 0;
  resize: vertical;
  background: #fff;
}
.tpl-modal-row input:focus,
.tpl-modal-row textarea:focus {
  border-color: #14b870;
  box-shadow: 0 0 0 3px rgba(20, 184, 112, 0.12);
}
.tpl-modal-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
}
.tpl-tag-btn {
  padding: 4px 10px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  font-size: 12px;
  font-family: 'SF Mono', Menlo, monospace;
  transition: background .15s ease, color .15s ease;
}
.tpl-tag-btn:hover { background: #14b870; color: #fff; border-color: #14b870; }
.tpl-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line, #e2e8f0);
  background: #f8fafc;
}
.tpl-modal-cancel {
  padding: 9px 16px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tpl-modal-cancel:hover { background: #f1f5f9; }
.tpl-modal-save {
  padding: 9px 16px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #14b870, #0f9d5d);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tpl-modal-save:hover { filter: brightness(1.05); }

@keyframes tplModalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes tplModalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* --- 4. rh-panel 重新展开按钮 (顶部右边小条) --- */
.rh-reopen-rail {
  position: fixed;
  top: 70px;
  right: 0;
  width: 28px;
  height: 64px;
  background: linear-gradient(180deg, #14b870, #0f9d5d);
  color: #fff;
  border: 0;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: -2px 2px 8px rgba(0,0,0,0.08);
  writing-mode: vertical-rl;
  letter-spacing: 0.1em;
}
.rh-reopen-rail:hover { filter: brightness(1.1); }
.rh-reopen-rail[hidden] { display: none; }

/* ============================================================
   v46 FIX — Non-chat views layout repair
   All non-chat pages (admin, devices, broadcast, tools) must
   use 2-column grid: rail(64px) + content(1fr).
   The duplicate old-css-block (line ~4822) was poisoning the
   grid with a stale 3-column + 2-row (with topbar) definition.
   This rule MUST be last in file to win the cascade.
   ============================================================ */
.app-html body:not([data-view="chat"]) .app-shell {
  grid-template-columns: 64px minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) !important;
  grid-template-areas: "rail content" !important;
  width: 100% !important;
  margin-left: 0 !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}
/* Ensure content-area fills the remaining space in non-chat views */
.app-html body:not([data-view="chat"]) .content-area {
  background: var(--bg) !important;
  min-width: 0 !important;
  max-width: none !important;
}

/* ============================================================
   v46 FIX 2: Force correct grid layouts for ALL non-chat pages
   ============================================================ */
/* Broadcast: 2 columns (left | right) */
body[data-view="broadcast"] .broadcast-studio {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  grid-template-rows: none !important;
}

/* Admin: 2 columns (left | right) - override auto-fit */
body[data-view="admin"] .admin-grid {
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1.4fr) !important;
}

/* Tools: auto-fit (keep original behavior) */
body[data-view="tools"] .tools-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
}

/* Devices: auto-fit (keep original behavior) */
body[data-view="devices"] .device-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
}

/* Ensure page-wrap fills content area */
body:not([data-view="chat"]) .page-wrap {
  width: 100% !important;
  max-width: none !important;
  flex: 1 1 auto !important;
}

/* ============================================================
   v54 MOBILE/UI CONSOLIDATION
   Split templates now place page content inside .content-area.
   These final rules own the responsive shell so older duplicated
   blocks above cannot force stale desktop columns on phones.
   ============================================================ */

.app-html,
.app-html body {
  width: 100%;
  max-width: 100%;
}

.app-html body {
  overflow: hidden;
}

.app-html .app-shell {
  width: 100%;
  max-width: 100vw;
}

.app-html body[data-view="chat"] .app-shell {
  grid-template-columns: 64px minmax(0, 1fr) !important;
  grid-template-areas: "rail content" !important;
}

.app-html body[data-view="chat"] .content-area {
  display: grid !important;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-areas: "filter page";
  min-width: 0;
  min-height: 0;
}

.app-html body[data-view="chat"] .content-area > .filter-column {
  grid-area: filter;
  width: auto !important;
  min-width: 0;
  height: 100%;
}

.app-html body[data-view="chat"] .content-area > #chat-view {
  grid-area: page;
  min-width: 0;
  min-height: 0;
}

.app-html .content-area > .view.active {
  display: flex !important;
  min-width: 0;
  min-height: 0;
}

.app-html .page-wrap {
  width: 100%;
  max-width: 100%;
}

.app-html .page-head {
  gap: 12px;
  min-width: 0;
}

.app-html .page-head > div {
  min-width: 0;
}

.app-html .page-head h1,
.app-html .page-head p,
.app-html .card-head h2,
.app-html .card-head span {
  overflow-wrap: anywhere;
}

.app-html .card,
.app-html .device-card,
.app-html .user-row,
.app-html .job,
.app-html .template-item,
.app-html .license-key-row,
.app-html .campaign-row,
.app-html .email-log-row {
  max-width: 100%;
}

.app-html input,
.app-html select,
.app-html textarea,
.app-html button {
  max-width: 100%;
}

.app-html textarea {
  resize: vertical;
}

.app-html .device-grid,
.app-html .tools-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)) !important;
}

.app-html body[data-view="broadcast"] .broadcast-studio,
.app-html body[data-view="admin"] .admin-grid,
.app-html body[data-view="admin"] .admin-grid-two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  min-width: 0;
}

.app-html .form-row,
.app-html .strategy-grid,
.app-html .template-form .form-row,
.app-html .broadcast-form .form-row,
.app-html .license-gen-form .form-row,
.app-html .tool-controls,
.app-html .permission-row,
.app-html .inline-actions {
  min-width: 0;
}

.app-html .target-row,
.app-html .tool-group-row,
.app-html .permission-chip,
.app-html .user-row,
.app-html .license-key-row,
.app-html .campaign-row,
.app-html .email-log-row {
  min-width: 0;
}

.app-html .target-row span,
.app-html .tool-group-row span,
.app-html .permission-chip span,
.app-html .user-row > div,
.app-html .lk-info,
.app-html .lk-meta,
.app-html .campaign-info,
.app-html .email-log-info {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .app-html body:not([data-view="chat"]) .app-shell {
    grid-template-columns: 56px minmax(0, 1fr) !important;
  }

  .app-html body[data-view="chat"] .app-shell {
    grid-template-columns: 56px minmax(0, 1fr) !important;
  }

  .app-html body[data-view="chat"] .content-area {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .app-html body[data-view="broadcast"] .broadcast-studio,
  .app-html body[data-view="admin"] .admin-grid,
  .app-html body[data-view="admin"] .admin-grid-two {
    grid-template-columns: 1fr !important;
  }

  .app-html .page-wrap {
    padding: 14px;
  }
}

@media (max-width: 720px) {
  .app-html body {
    background: var(--bg);
  }

  .app-html .app-shell,
  .app-html body[data-view="chat"] .app-shell,
  .app-html body:not([data-view="chat"]) .app-shell {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) 64px !important;
    grid-template-areas:
      "content"
      "rail" !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  .app-html .icon-rail,
  .app-html body[data-view="chat"] .icon-rail {
    grid-area: rail !important;
    display: grid !important;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-flow: column;
    align-items: center;
    justify-items: center;
    gap: 2px;
    width: 100%;
    height: 64px;
    min-height: 64px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid #1e293b;
    overflow: visible;
  }

  .app-html .rail-brand,
  .app-html .rail-spacer {
    display: none !important;
  }

  .app-html .rail-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px;
  }

  .app-html .rail-btn.active::before {
    left: 10px;
    right: 10px;
    top: auto;
    bottom: -7px;
    width: auto;
    height: 3px;
    border-radius: 3px 3px 0 0;
  }

  .app-html .content-area,
  .app-html body[data-view="chat"] .content-area {
    grid-area: content !important;
    display: block !important;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  .app-html .content-area > .view.active {
    height: 100%;
  }

  .app-html body[data-view="chat"] .content-area > .filter-column {
    position: fixed !important;
    inset: 0 0 64px 0;
    z-index: 70;
    display: none !important;
    width: 100% !important;
    height: auto !important;
    padding: 16px;
    border: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 60px rgba(15, 23, 42, 0.2);
  }

  .app-html body[data-view="chat"] .content-area > .filter-column.is-open {
    display: flex !important;
  }

  .app-html body[data-view="chat"] .chat-page {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) !important;
    height: 100%;
  }

  .app-html body[data-view="chat"]:not([data-mobile-chat="active"]) .chat-column {
    display: none !important;
  }

  .app-html body[data-view="chat"]:not([data-mobile-chat="active"]) .list-column {
    display: grid !important;
    border-right: 0;
  }

  .app-html body[data-view="chat"][data-mobile-chat="active"] .list-column {
    display: none !important;
  }

  .app-html body[data-view="chat"][data-mobile-chat="active"] .chat-column {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .app-html body[data-view="chat"][data-mobile-chat="active"] .chat-back-btn,
  .app-html body[data-view="chat"]:not([data-mobile-chat="active"]) .mobile-filter-toggle {
    display: inline-flex !important;
  }

  .app-html .list-head,
  .app-html .thread-head {
    min-height: 56px;
    padding: 8px 10px;
  }

  .app-html .thread-actions {
    gap: 4px;
  }

  .app-html .thread-select,
  .app-html #export-members span {
    display: none !important;
  }

  .app-html .messages {
    padding: 10px 8px;
    -webkit-overflow-scrolling: touch;
  }

  .app-html .message-row {
    max-width: 100%;
  }

  .app-html .message {
    max-width: min(82vw, 520px);
    overflow-wrap: anywhere;
  }

  .app-html .composer {
    padding: 8px;
  }

  .app-html .composer-input-wrap {
    gap: 7px;
  }

  .app-html .composer-input textarea {
    min-height: 44px;
    max-height: 30dvh;
    font-size: 16px;
  }

  .app-html .composer-actions #send {
    min-width: 48px;
    height: 44px;
    padding: 0 12px;
  }

  .app-html .page-wrap {
    height: 100%;
    padding: 12px;
    gap: 12px;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .app-html .page-head {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
  }

  .app-html .page-head h1 {
    font-size: 22px;
    line-height: 1.15;
  }

  .app-html .outline-button,
  .app-html .page-head button {
    min-height: 42px;
  }

  .app-html .card {
    border-radius: 12px;
    padding: 14px;
  }

  .app-html .card-head {
    gap: 8px;
    align-items: flex-start;
  }

  .app-html .device-grid,
  .app-html .tools-grid,
  .app-html body[data-view="broadcast"] .broadcast-studio,
  .app-html body[data-view="admin"] .admin-grid,
  .app-html body[data-view="admin"] .admin-grid-two,
  .app-html .form-row,
  .app-html .strategy-grid,
  .app-html .broadcast-mode-tabs,
  .app-html .tool-controls,
  .app-html .permission-row,
  .app-html .license-filter-row {
    grid-template-columns: 1fr !important;
  }

  .app-html .account-form,
  .app-html .contact-import,
  .app-html .broadcast-form,
  .app-html .template-form,
  .app-html .user-form,
  .app-html .campaign-compose {
    gap: 10px;
  }

  .app-html .account-form label,
  .app-html .contact-import label,
  .app-html .broadcast-form label,
  .app-html .template-form label,
  .app-html .user-form label,
  .app-html .strategy-grid label,
  .app-html .tool-controls label {
    min-width: 0;
  }

  .app-html .inline-actions,
  .app-html .form-actions,
  .app-html .row-actions,
  .app-html .device-card footer,
  .app-html .login-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .app-html .inline-actions button,
  .app-html .form-actions button,
  .app-html .row-actions button,
  .app-html .device-card footer button,
  .app-html .login-actions button,
  .app-html #broadcast-send,
  .app-html #save-template,
  .app-html #add-account,
  .app-html #load-tool-groups,
  .app-html #export-tool-groups,
  .app-html #generate-license-keys,
  .app-html #send-campaign {
    width: 100%;
    min-height: 42px;
  }

  .app-html .target-list,
  .app-html .template-list,
  .app-html .jobs,
  .app-html .user-list,
  .app-html .tool-group-list,
  .app-html .permission-list,
  .app-html .license-key-list,
  .app-html .email-logs-list {
    max-height: none !important;
    overflow: visible !important;
  }

  .app-html .target-row,
  .app-html .tool-group-row,
  .app-html .permission-chip {
    align-items: flex-start;
  }

  .app-html .user-row,
  .app-html .license-key-row,
  .app-html .campaign-row,
  .app-html .email-log-row {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .app-html .translate-panel,
  .app-html .templates-panel,
  .app-html .rail-user-menu {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 74px !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    max-height: min(72dvh, 560px);
    z-index: 90;
  }

  .app-html .tpl-modal {
    width: calc(100vw - 24px);
    max-width: none;
    max-height: calc(100dvh - 32px);
  }

  .app-html .tpl-modal-foot {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .app-html .icon-rail,
  .app-html body[data-view="chat"] .icon-rail {
    height: 60px;
    min-height: 60px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .app-html .rail-btn {
    width: 40px !important;
    height: 40px !important;
  }

  .app-html .rail-btn svg {
    width: 18px;
    height: 18px;
  }

  .app-html .message {
    max-width: 86vw;
  }
}


/* ═══════════════════════════════════════════════════════════════
   v55 — Non-chat pages: clean whites, modern forms & checkboxes
   ═══════════════════════════════════════════════════════════════ */

/* Non-chat pages — white background, no patterned bg */
body:not([data-view="chat"]) .content-area {
  background: #f8fafc;
}
body:not([data-view="chat"]) .page-wrap {
  background: transparent;
}
body:not([data-view="chat"]) .app-shell {
  background: #f8fafc;
}

/* Cards in non-chat pages */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
}
.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}
.card-head span {
  font-size: 12px;
  color: #94a3b8;
}
.card-body {
  padding: 16px 18px;
}
.card-foot {
  padding: 10px 18px;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.card-desc {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Form fields */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.form-field span {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.form-field span em { color: #ef4444; font-style: normal; }
.form-field input,
.form-field select,
.form-field textarea {
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.form-field input::placeholder,
.form-field textarea::placeholder { color: #9ca3af; }
.form-field input:disabled,
.form-field select:disabled {
  background: #f9fafb;
  color: #9ca3af;
}
.form-error {
  color: #dc2626;
  font-size: 13px;
  margin: 6px 0 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(99,102,241,.35); transform: translateY(-1px); }
.btn-outline {
  background: #fff;
  color: #374151;
  border: 1.5px solid #d1d5db;
}
.btn-outline:hover { border-color: #6366f1; color: #4f46e5; background: #f5f3ff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger-outline { background: #fff; color: #ef4444; border: 1.5px solid #fca5a5; }
.btn-danger-outline:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* Checkbox / Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 22px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.toggle-switch input:checked + .toggle-slider { background: #6366f1; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
}
.data-table tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0e7ff; color: #3730a3; }

/* Empty state */
.empty-state {
  padding: 32px 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  max-width: 480px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modal-enter .2s ease;
}
@keyframes modal-enter {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; border: 0; background: #f3f4f6;
  border-radius: 8px; font-size: 18px; color: #6b7280; cursor: pointer;
}
.modal-close:hover { background: #e5e7eb; }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  margin-top: 8px;
}

/* Page header */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #111827;
  letter-spacing: -.02em;
}
.page-head p {
  margin: 4px 0 0;
  font-size: 13px;
  color: #6b7280;
}
.page-head small {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6366f1;
}
.page-sub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  margin-bottom: 12px;
}
.page-sub-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.page-sub-head p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #6b7280;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  z-index: 2000;
  opacity: 0;
  transition: all .25s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: #dc2626; }

/* Status row (settings page) */
.status-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.status-label { color: #6b7280; }
.status-value { font-weight: 600; color: #111827; }

/* Setting row */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
}
.setting-row-label strong { display: block; font-size: 14px; color: #111827; }
.setting-row-label small { font-size: 12px; color: #6b7280; }
.setting-row-control { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.setting-divider { height: 1px; background: #f1f5f9; margin: 4px 0; }
.setting-select {
  padding: 6px 10px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: #374151;
}
.settings-save-bar { padding-top: 12px; display: flex; justify-content: flex-end; }
.settings-renew-btn { margin-top: 14px; width: 100%; }

/* License form */
.license-activate-form {
  display: flex;
  gap: 8px;
}
.license-activate-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: monospace;
  letter-spacing: .05em;
}
.license-activate-form input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
  outline: none;
}
.license-result { margin-top: 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.license-success { background: #dcfce7; color: #166534; }
.license-error { background: #fee2e2; color: #991b1b; }

/* Outline button (reload etc) */
.outline-button {
  padding: 6px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.outline-button:hover { border-color: #6366f1; color: #4f46e5; }

/* Account page specific */
.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.account-profile-card { grid-column: 1 / -1; }
.account-profile-body {
  display: flex;
  gap: 20px;
  align-items: center;
}
.account-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  flex-shrink: 0;
}
.account-profile-info { flex: 1; }
.account-profile-row {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
}
.account-profile-row label { color: #6b7280; min-width: 90px; }
.account-profile-row span { color: #111827; font-weight: 600; }
.account-section { margin-top: 24px; }

/* Plan card */
.plan-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #dbeafe, #e0e7ff);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4f46e5;
  margin-bottom: 12px;
}
.plan-icon-wrap svg { width: 22px; height: 22px; }
.plan-name-display { font-size: 18px; font-weight: 700; color: #111827; margin-bottom: 8px; }
.plan-expiry-row {
  display: flex;
  gap: 24px;
  margin-bottom: 4px;
}
.plan-expiry-item small { display: block; font-size: 11px; color: #6b7280; text-transform: uppercase; }
.plan-expiry-item span { font-size: 14px; font-weight: 600; color: #111827; }
.seats-badge {
  display: inline-block;
  background: #e0e7ff;
  color: #4f46e5;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
}
.team-seats-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6b7280;
}
.seats-cost-preview {
  margin: 12px 0;
  font-size: 15px;
  color: #111827;
}
.seats-cost-preview strong { color: #6366f1; }

/* Settings grid */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}
.settings-card .card-body { padding: 0 18px 16px; }
.settings-form {
  display: flex;
  flex-direction: column;
  padding-top: 10px;
}

/* Pricing page */
.pricing-current-badge {
  flex-shrink: 0;
}
.pricing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 0 0 28px;
}
.pricing-card {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .15s, box-shadow .15s;
  position: relative;
}
.pricing-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.pricing-card-featured {
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
}
.pricing-card-badge {
  position: absolute;
  top: -10px;
  right: 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.pricing-card-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.pricing-card-head p { margin: 2px 0 0; font-size: 12px; color: #6b7280; }
.pricing-card-price {
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.price-currency { font-size: 18px; font-weight: 700; color: #6366f1; }
.price-amount { font-size: 32px; font-weight: 800; color: #111827; line-height: 1; }
.price-period { font-size: 13px; color: #6b7280; }
.pricing-card-features ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pricing-card-features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
}
.pricing-card-features li svg {
  width: 16px;
  height: 16px;
  color: #22c55e;
  flex-shrink: 0;
}
.pricing-card-price-per-day {
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
}
.pricing-section { margin-bottom: 24px; }

/* Payment instructions */
.payment-instructions { display: flex; flex-direction: column; gap: 14px; }
.payment-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.payment-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4f46e5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.payment-step strong { display: block; font-size: 14px; color: #111827; margin-bottom: 4px; }
.payment-step p { margin: 0; font-size: 13px; color: #6b7280; line-height: 1.6; }

/* Order modal */
.order-summary {
  background: #f8fafc;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.order-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
}
.order-summary-row span { color: #6b7280; }
.order-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: #fefce8;
  border-radius: 8px;
  font-size: 12px;
  color: #92400e;
  margin-bottom: 8px;
}
.order-notice svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════════════
/* Codex v68: rail color refresh, layout unchanged */
.app-html .icon-rail {
  background: linear-gradient(180deg, #07111f 0%, #0d1726 58%, #101827 100%);
  border-right: 1px solid rgba(148, 163, 184, .16);
}

.app-html .rail-brand {
  background: linear-gradient(135deg, #10b981, #06b6d4);
  box-shadow: 0 10px 24px rgba(6, 182, 212, .24);
}

.app-html .rail-btn {
  color: #a8b3c7;
}

.app-html .rail-btn:hover {
  background: rgba(20, 184, 166, .12);
  color: #f8fafc;
}

.app-html .rail-btn.active {
  background: rgba(16, 185, 129, .18);
  color: #ecfeff;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, .22);
}

.app-html .rail-btn.active::before {
  background: #22d3ee;
  box-shadow: 0 0 12px rgba(34, 211, 238, .7);
}
.message-revoked {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 5px;
  background: #eef2f7;
  color: #667085;
  font-size: 11px;
  font-weight: 700;
}

.message-revoke-btn {
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 1px 4px;
}

.message-revoke-btn:hover {
  color: #b42318;
}

.message-body.is-revoked {
  color: #667085;
  font-style: italic;
}

.media-audio {
  display: block;
  width: min(280px, 100%);
  margin-top: 8px;
}

/* Codex v69: chat density + fixed account column alignment */
.app-html body[data-view="chat"] .app-shell {
  grid-template-columns: 64px minmax(0, 1fr) !important;
  gap: 0 !important;
}

.app-html body[data-view="chat"] .content-area {
  grid-template-columns: 232px minmax(0, 1fr) !important;
  gap: 0 !important;
  background: #f3f2ec !important;
}

.app-html body[data-view="chat"] .content-area > .filter-column {
  margin-left: 0 !important;
  padding-left: 12px !important;
  padding-right: 10px !important;
  box-sizing: border-box !important;
  border-left: 0 !important;
  transform: none !important;
  z-index: 2;
}

.app-html body[data-view="chat"] .filter-column,
.app-html body[data-view="chat"] #accounts,
.app-html body[data-view="chat"] .account-list,
.app-html body[data-view="chat"] .account-list-items {
  max-width: 100% !important;
}

.app-html body[data-view="chat"] .account-list-item,
.app-html body[data-view="chat"] .account-option,
.app-html body[data-view="chat"] .account-chip {
  box-sizing: border-box !important;
}

.app-html body[data-view="chat"] #chat-view {
  margin-left: 0 !important;
  padding-left: 0 !important;
  transform: none !important;
}

.app-html body[data-view="chat"] .chat-page {
  gap: 0 !important;
  column-gap: 0 !important;
  background: #f3f2ec !important;
}

.app-html body[data-view="chat"] .list-column {
  border-left: 0 !important;
  margin-left: 0 !important;
}

.app-html body[data-view="chat"] .thread {
  margin-left: 0 !important;
  border-left: 1px solid rgba(17, 24, 39, .08) !important;
}

.app-html body[data-view="chat"] .conversation-list {
  padding-right: 4px !important;
}

/* Codex v70: final page shell placement.
   Split pages render content directly under .app-shell, so these rules
   explicitly place each direct child instead of relying on older wrappers. */
.app-html .app-shell {
  display: grid !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  min-height: 0 !important;
  grid-template-rows: minmax(0, 1fr) !important;
  grid-template-columns: 64px minmax(0, 1fr) !important;
  grid-template-areas: "rail content" !important;
  overflow: hidden !important;
  gap: 0 !important;
}

.app-html .icon-rail {
  grid-area: rail !important;
  position: relative !important;
  z-index: 20 !important;
  width: 64px !important;
  min-width: 64px !important;
  height: 100dvh !important;
}

.app-html body[data-view="chat"] .app-shell {
  grid-template-columns: 64px 220px minmax(0, 1fr) !important;
  grid-template-areas: "rail filter content" !important;
  background: #f1f0ea !important;
}

.app-html body[data-view="chat"] .filter-column {
  grid-area: filter !important;
  width: 220px !important;
  min-width: 0 !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: 12px 10px !important;
  transform: none !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  border-left: 0 !important;
}

.app-html body[data-view="chat"] #chat-view {
  grid-area: content !important;
  width: 100% !important;
  min-width: 0 !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  overflow: hidden !important;
}

.app-html body[data-view="chat"] .chat-page {
  width: 100% !important;
  min-width: 0 !important;
  height: 100% !important;
  max-height: 100dvh !important;
  display: grid !important;
  grid-template-columns: 340px minmax(0, 1fr) !important;
  gap: 0 !important;
  margin: 0 !important;
  transform: none !important;
}

.app-html body[data-view="chat"] .list-column,
.app-html body[data-view="chat"] .chat-column {
  min-width: 0 !important;
  height: 100% !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
}

.app-html body[data-view="chat"] .account-list-item {
  max-width: 100% !important;
}

.app-html body[data-view="chat"] .account-list-item-text,
.app-html body[data-view="chat"] .account-list-item-text strong,
.app-html body[data-view="chat"] .account-list-item-text small {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.app-html body:not([data-view="chat"]) .app-shell > .page-wrap,
.app-html body:not([data-view="chat"]) .app-shell > .view,
.app-html body:not([data-view="chat"]) .app-shell > .content-area {
  grid-area: content !important;
  min-width: 0 !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100dvh !important;
  overflow: auto !important;
}

.app-html body:not([data-view="chat"]) .page-wrap {
  padding-left: 28px !important;
  padding-right: 28px !important;
  box-sizing: border-box !important;
}

.app-html body[data-view="admin"] .page-wrap {
  background: #f6f7f4 !important;
}

.app-html body[data-view="admin"] .admin-tabs {
  position: sticky !important;
  top: 0 !important;
  z-index: 5 !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  padding: 10px !important;
  margin: 14px 0 !important;
  border: 1px solid #e1e5dd !important;
  border-radius: 8px !important;
  background: rgba(255, 255, 255, .94) !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06) !important;
}

.app-html body[data-view="admin"] .admin-tab {
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  min-height: 34px !important;
  padding: 0 12px !important;
  border-radius: 7px !important;
  border: 1px solid #d9dfd7 !important;
  background: #fff !important;
  color: #26332d !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}

.app-html body[data-view="admin"] .admin-tab.active {
  border-color: #0f8f68 !important;
  background: #0f8f68 !important;
  color: #fff !important;
}

@media (max-width: 860px) {
  .app-html .app-shell,
  .app-html body[data-view="chat"] .app-shell {
    grid-template-columns: 56px minmax(0, 1fr) !important;
    grid-template-areas: "rail content" !important;
  }

  .app-html body[data-view="chat"] .filter-column {
    position: fixed !important;
    left: 56px !important;
    top: 0 !important;
    bottom: 0 !important;
    width: min(260px, calc(100vw - 56px)) !important;
    z-index: 30 !important;
    transform: translateX(-110%) !important;
    transition: transform .18s ease !important;
  }

  .app-html body[data-view="chat"] .filter-column.is-open {
    transform: translateX(0) !important;
  }

  .app-html body[data-view="chat"] .chat-page {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   v72: Mobile chat entry polish
   - no account drawer button on phones
   - account selector lives inside conversation filters
   - offline accounts show QR in the first visible list pane
   ============================================================ */
.mobile-account-filter {
  display: none;
}

.mobile-login-card {
  margin: 14px 10px 24px;
  padding: 14px;
  border: 1px solid rgba(14, 116, 109, .22);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f6fbf8 100%);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
}

.mobile-login-copy {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: center;
}

.mobile-login-copy small {
  color: #0e746d;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.mobile-login-copy strong {
  grid-column: 1 / -1;
  min-width: 0;
  color: #15231f;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.mobile-login-copy p {
  grid-column: 1 / -1;
  margin: 2px 0 12px;
  color: #60716b;
  font-size: 13px;
  line-height: 1.45;
}

.mobile-login-qr {
  display: grid;
  place-items: center;
  min-height: 210px;
  padding: 12px;
  border: 1px solid rgba(14, 116, 109, .16);
  border-radius: 8px;
  background: #fff;
}

.mobile-login-qr img {
  width: min(230px, 72vw);
  max-width: 100%;
  border-radius: 6px;
}

.mobile-login-qr pre {
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  color: #52645e;
  font-size: 12px;
}

.mobile-login-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.mobile-login-actions button {
  min-height: 38px;
  border: 1px solid rgba(14, 116, 109, .22);
  border-radius: 8px;
  background: #fff;
  color: #15231f;
  font-weight: 800;
}

.mobile-login-actions button.primary {
  background: #0e746d;
  border-color: #0e746d;
  color: #fff;
}

@media (max-width: 860px) {
  .app-html body[data-view="chat"]:not([data-mobile-chat="active"]) .mobile-filter-toggle {
    display: none !important;
  }

  .app-html body[data-view="chat"] .list-head {
    grid-template-columns: 36px 1fr 36px;
  }

  .app-html body[data-view="chat"] .list-head h2 {
    text-align: center;
  }

  .app-html body[data-view="chat"] .filter-row {
    gap: 6px;
  }

  .app-html body[data-view="chat"] .filter-chips {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
  }

  .app-html body[data-view="chat"] .filter-chip {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }

  .app-html body[data-view="chat"] .filter-chip-label {
    display: none !important;
  }

  .app-html body[data-view="chat"] .filter-row-right {
    flex: 1 1 auto;
    min-width: 0;
    gap: 4px;
  }

  .app-html body[data-view="chat"] .mobile-account-filter {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    min-width: 86px;
    max-width: 128px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .app-html body[data-view="chat"] .mobile-account-select {
    width: 100%;
    min-width: 0;
    height: 34px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #15231f;
    font-size: 12px;
    font-weight: 700;
  }

  .app-html body[data-view="chat"] .filter-list-wrap {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }

  .app-html body[data-view="chat"] .filter-list-select {
    position: absolute;
    inset: 0;
    width: 36px;
    opacity: 0;
  }

  .app-html body[data-view="chat"] .filter-search-wrap {
    flex: 1 1 84px;
    min-width: 0;
  }

  .app-html body[data-view="chat"] .mobile-login-card {
    margin-top: 12px;
  }
}

/* v78: Tools — Export All Contacts hint */
.tool-hint {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* v78: Broadcast targets — compact + hint */
.broadcast-targets-card .target-list.compact {
  gap: 5px;
  padding: 8px 12px;
  max-height: 220px;
}
.broadcast-targets-card .target-list.compact .target-row {
  padding: 7px 10px;
}
.broadcast-targets-card .card-hint {
  margin: 0;
  padding: 9px 14px 12px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid rgba(54, 70, 63, .1);
  background: rgba(54, 70, 63, .03);
}
