/* ============================================================
   Team WhatsApp — design system
   Dark, layered, WhatsApp-Web-familiar but elevated.
   NOTE: every selector/class used by app.js is preserved.
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* surfaces (layered elevation) */
  --bg-deep: #0a1014;
  --bg-panel: #111b21;
  --bg-panel-2: #1c2a33;
  --bg-hover: #24343f;
  --bg-active: #2a3b47;
  --bg-input: #24343f;
  --border: rgba(134, 150, 160, 0.14);
  --border-strong: rgba(134, 150, 160, 0.24);

  /* text */
  --text: #e9edef;
  --text-muted: #8696a0;
  --text-faint: #667781;

  /* brand */
  --green: #00a884;
  --green-bright: #06cf9c;
  --green-deep: #005c4b;
  --blue: #53bdeb;
  --red: #f15c6d;
  --amber: #ffd279;

  /* bubbles */
  --bubble-in: #1f2c34;
  --bubble-out: #005c4b;

  /* geometry */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  /* depth */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.5);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.app-body { display: flex; flex: 1; min-height: 0; }

/* ---------- Account tabs (Chrome-style, one per WhatsApp) ---------- */
.acc-tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  background: #05090c;
  border-bottom: 1px solid var(--border);
  padding: 6px 8px 0;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.acc-tabs::-webkit-scrollbar { display: none; }
.acc-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(28, 42, 51, 0.55);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 200px;
  transition: background 0.15s ease, color 0.15s ease;
}
.acc-tab:hover { background: var(--bg-hover); color: var(--text); }
.acc-tab.active {
  background: var(--bg-panel);
  color: var(--text);
  font-weight: 600;
  border-color: var(--border-strong);
}
.acc-tab .acc-name { overflow: hidden; text-overflow: ellipsis; }
.acc-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.acc-dot.on { background: var(--green-bright); box-shadow: 0 0 6px rgba(6, 207, 156, 0.6); }
.acc-dot.qr { background: var(--amber); }
.acc-dot.off { background: var(--text-faint); }
.acc-unread {
  background: var(--green-bright);
  color: #06251d;
  font-size: 10.5px; font-weight: 700;
  border-radius: var(--r-full);
  padding: 0 6px;
  min-width: 17px;
  text-align: center;
}
.acc-add {
  max-width: none;
  padding: 8px 13px;
  font-size: 16px;
  font-weight: 700;
  color: var(--green-bright);
}
.acc-check {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--text-muted);
  margin-right: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.acc-check input { accent-color: var(--green); }
.user-access { max-width: 220px; }

::selection { background: rgba(0, 168, 132, 0.35); }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb {
  background: rgba(134, 150, 160, 0.25);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(134, 150, 160, 0.45); }
* { scrollbar-width: thin; scrollbar-color: rgba(134, 150, 160, 0.25) transparent; }

/* ============================================================
   Sidebar
   ============================================================ */
#sidebar {
  width: 380px;
  min-width: 380px; /* never shrink into a width where the admin's 7-icon action row overlaps the avatar */
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  min-height: 62px;
}
.me { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 15px; letter-spacing: 0.1px; min-width: 0; }
.me #me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Clear breathing room between the name and the action buttons, and a bit
   more space around the ban-risk pill so it never looks glued to the name.
   The row is intentionally compact: with the ban-risk pill it can hold up to
   ~7 controls, so the icons here are a touch smaller than app-wide .icon-btn
   and never crowd (let alone overlap) the avatar. */
.sidebar-actions { display: flex; align-items: center; gap: 3px; margin-left: 8px; flex-shrink: 0; }
.sidebar-actions .risk-btn { margin-right: 3px; }
.sidebar-actions .icon-btn { width: 36px; height: 36px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #5d6b73;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px;
  flex-shrink: 0;
  user-select: none;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.avatar-me { width: 36px; height: 36px; font-size: 14px; background: linear-gradient(135deg, var(--green), #017561); flex-shrink: 0; }

/* ---------- Icon buttons ---------- */
.icon-btn {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.send-btn { color: var(--green-bright); font-size: 20px; }

/* ---------- Connection banner ---------- */
.wa-banner {
  padding: 10px 16px;
  font-size: 13px;
  background: rgba(255, 210, 121, 0.08);
  color: var(--amber);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.wa-banner.ok { color: #7ae0b8; background: rgba(0, 168, 132, 0.08); }

/* ---------- Search ---------- */
.search-wrap { padding: 10px 12px 8px; background: var(--bg-panel); }
.search-wrap input {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  padding: 9px 18px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.search-wrap input:focus { border-color: var(--green); background: var(--bg-input); }
.search-wrap input::placeholder { color: var(--text-faint); }

/* ---------- Chat list ---------- */
.chat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 6px 10px; }

.archived-row {
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--green);
  cursor: pointer;
  border-radius: var(--r-md);
  margin: 2px 2px 4px;
  transition: background 0.15s ease;
}
.archived-row:hover { background: var(--bg-hover); }

.chat-item {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 12px;
  cursor: pointer;
  border-radius: var(--r-md);
  margin: 1px 2px;
  transition: background 0.14s ease;
  animation: fadeIn 0.18s ease both;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active {
  background: var(--bg-active);
  box-shadow: inset 3px 0 0 var(--green);
}
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-item-name {
  font-size: 15.5px; font-weight: 500; letter-spacing: 0.1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item-time { font-size: 11.5px; color: var(--text-faint); flex-shrink: 0; }
.chat-item-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; gap: 6px; }
.chat-item-preview {
  font-size: 13.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item-icons { font-size: 11px; flex-shrink: 0; opacity: 0.85; }
.unread-badge {
  background: var(--green-bright);
  color: #062b22;
  font-size: 11.5px; font-weight: 700;
  border-radius: var(--r-full);
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
  animation: badgePop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-item.has-unread .chat-item-name { font-weight: 600; color: var(--text); }
.chat-item.has-unread .chat-item-preview { font-weight: 500; color: #cfd9de; }
.chat-item.has-unread .chat-item-time { color: var(--green-bright); }

/* ---------- Skeleton shimmer (initial load) ---------- */
.skeleton-item {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 12px; margin: 1px 2px;
}
.sk {
  background: linear-gradient(90deg, var(--bg-panel-2) 25%, var(--bg-hover) 50%, var(--bg-panel-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
.sk-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.sk-line { height: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   Main / chat view
   ============================================================ */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  min-width: 0;
}

.empty-state {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(0, 168, 132, 0.05), transparent 60%),
    var(--bg-deep);
  border-bottom: 4px solid var(--green);
}
.empty-state svg { opacity: 0.55; filter: drop-shadow(0 8px 24px rgba(0, 168, 132, 0.15)); }
.empty-state h2 { color: var(--text); font-weight: 300; font-size: 30px; letter-spacing: 0.3px; }
.empty-state p { font-size: 14px; line-height: 1.6; }

#chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }

.chat-header {
  display: flex; align-items: center; gap: 13px;
  padding: 9px 16px;
  background: rgba(28, 42, 51, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  min-height: 62px;
  z-index: 3;
  cursor: default;
}
.chat-header .avatar { width: 40px; height: 40px; font-size: 15px; }
.chat-header-info { min-width: 0; }
.chat-header-name { font-size: 15.5px; font-weight: 600; letter-spacing: 0.1px; }
.chat-header-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

/* ---------- Messages canvas (hand-drawn doodle wallpaper) ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 7% 14px;
  display: flex; flex-direction: column; gap: 3px;
  background-color: #0b141a;
  background-image: url("data:image/svg+xml,%3Csvg width='260' height='260' viewBox='0 0 260 260' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23182229' stroke-width='1.6'%3E%3Ccircle cx='36' cy='40' r='9'/%3E%3Cpath d='M120 30q10-14 20 0t-20 22q-10-14 0-22'/%3E%3Crect x='196' y='24' width='22' height='16' rx='5'/%3E%3Cpath d='M212 40l-6 8v-8'/%3E%3Cpath d='M40 130c0-10 8-18 18-18s18 8 18 18'/%3E%3Ccircle cx='150' cy='120' r='4'/%3E%3Ccircle cx='168' cy='112' r='2.5'/%3E%3Cpath d='M220 128q8-10 16 0'/%3E%3Cpath d='M28 210q12 10 24 0'/%3E%3Ccircle cx='120' cy='208' r='11'/%3E%3Cpath d='M114 208l5 5 8-9'/%3E%3Cpath d='M196 200h26M196 208h18M196 216h22'/%3E%3Cpath d='M78 66l6 6m0-6l-6 6'/%3E%3Cpath d='M244 74l5 5m0-5l-5 5'/%3E%3Cpath d='M92 166a7 7 0 1 1 0 .01'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 260px 260px;
}

/* ---------- Bubbles ---------- */
.msg {
  max-width: 62%;
  padding: 7px 10px 8px;
  border-radius: var(--r-md);
  font-size: 14.2px;
  line-height: 1.42;
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow-1);
  animation: msgIn 0.16s ease both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes badgePop { from { transform: scale(0.4); } }

.msg.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 4px; }
.msg.out {
  background: linear-gradient(180deg, #016f5c 0%, var(--bubble-out) 100%);
  align-self: flex-end;
  border-top-right-radius: 4px;
}
.msg.pending { opacity: 0.6; font-style: italic; }
.msg.highlight { outline: 2px solid var(--green-bright); outline-offset: 2px; transition: outline 0.3s; }

.msg-sender { font-size: 12.5px; font-weight: 600; color: var(--blue); margin-bottom: 2px; }
.msg-via { font-size: 11px; color: #7ae0b8; margin-bottom: 3px; font-style: italic; opacity: 0.9; }
.msg-deleted { color: var(--text-muted); font-style: italic; font-size: 13.5px; }

/* Admin-only deletion log: shows who deleted a message and what it said.
   Deliberately distinct (dashed amber frame) so an admin can tell at a glance
   this is an audit view, not a normal message. */
.msg-deleted-log {
  border: 1px dashed rgba(255, 210, 121, 0.55);
  background: rgba(255, 210, 121, 0.07);
  border-radius: 8px;
  padding: 6px 9px;
  margin: 1px 0 2px;
  max-width: 100%;
}
.msg-deleted-log-head { font-size: 11.5px; font-weight: 600; color: var(--amber); margin-bottom: 3px; }
.msg-deleted-log-body { font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word; opacity: 0.92; }
.msg-deleted-log-edited { font-size: 12px; color: var(--text-muted); margin-top: 3px; white-space: pre-wrap; word-break: break-word; font-style: italic; }
.msg-deleted-log .msg-media { max-width: 240px; max-height: 240px; border-radius: 6px; margin: 2px 0 4px; display: block; }
.msg-deleted-log-doc { display: inline-block; color: var(--blue); text-decoration: none; font-size: 13.5px; margin: 2px 0 4px; }
.msg-deleted-log-doc:hover { text-decoration: underline; }

/* Admin panel: consolidated "Deleted messages" list */
.deletions-list { display: flex; flex-direction: column; gap: 6px; max-height: 56vh; overflow-y: auto; }
.deletion-row { border: 1px solid var(--border); border-left: 3px solid var(--amber); border-radius: 8px; padding: 8px 10px; cursor: pointer; transition: background 0.12s ease; }
.deletion-row:hover { background: var(--bg-hover); }
.deletion-row-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 3px; }
.deletion-who { font-weight: 600; font-size: 13px; color: var(--amber); }
.deletion-meta { font-size: 11.5px; color: var(--text-muted); }
.deletion-preview { font-size: 13.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; opacity: 0.92; }
.deletion-media-tag { display: inline-block; font-size: 10.5px; font-weight: 600; color: var(--blue); border: 1px solid var(--blue); border-radius: 4px; padding: 0 4px; margin-left: 4px; opacity: 0.85; }

/* Admin-only: the pre-edit original text under an edited message */
.msg-edit-orig { font-size: 12px; color: var(--amber); opacity: 0.85; margin-top: 2px; font-style: italic; white-space: pre-wrap; word-break: break-word; border-left: 2px solid rgba(255, 210, 121, 0.5); padding-left: 6px; }

.msg-time {
  font-size: 10.5px; color: rgba(233, 237, 239, 0.55);
  float: right;
  margin: 8px -2px -4px 10px;
  user-select: none;
  white-space: nowrap;
}
.msg.in .msg-time { color: var(--text-faint); }
.msg-ticks { font-size: 11px; letter-spacing: -2px; color: rgba(233, 237, 239, 0.55); }
.msg-ticks.read { color: var(--blue); }

.msg img.msg-media, .msg video.msg-media {
  max-width: 100%; max-height: 340px;
  border-radius: var(--r-sm);
  display: block; margin-bottom: 5px;
  cursor: pointer;
}
.msg audio { max-width: 260px; display: block; margin: 2px 0; }
.msg .doc-link {
  display: flex; align-items: center; gap: 9px;
  background: rgba(0, 0, 0, 0.22);
  padding: 11px 12px;
  border-radius: var(--r-sm);
  color: var(--text);
  text-decoration: none;
  margin-bottom: 5px;
  font-size: 13.5px;
  transition: background 0.15s ease;
}
.msg .doc-link:hover { background: rgba(0, 0, 0, 0.38); }
.media-placeholder {
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--r-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 5px;
}
.media-placeholder:hover { color: var(--text); }

.day-divider {
  align-self: center;
  background: rgba(24, 34, 41, 0.92);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: var(--r-sm);
  margin: 14px 0 8px;
  box-shadow: var(--shadow-1);
}

/* ---------- Quotes ---------- */
.msg-quote {
  border-left: 4px solid var(--green-bright);
  background: rgba(0, 0, 0, 0.24);
  border-radius: var(--r-sm);
  padding: 7px 11px;
  margin-bottom: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.15s ease;
}
.msg-quote:hover { background: rgba(0, 0, 0, 0.36); }
.msg-quote-title { font-size: 12px; font-weight: 600; color: var(--green-bright); }
.msg-quote-text {
  font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 380px;
  margin-top: 1px;
}

/* ---------- Reactions ---------- */
.msg-reactions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.react-chip {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  padding: 2px 9px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  box-shadow: var(--shadow-1);
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.react-chip:hover { transform: scale(1.08); }
.react-chip.mine { border-color: var(--green); background: rgba(0, 168, 132, 0.16); }

/* ---------- Per-message menu ---------- */
.msg-menu-btn {
  position: absolute;
  top: 3px; right: 5px;
  background: none; border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  transition: opacity 0.12s ease, background 0.12s ease;
}
.msg:hover .msg-menu-btn { opacity: 1; background: rgba(0, 0, 0, 0.35); }

.msg-menu {
  position: fixed;
  z-index: 200;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  padding: 6px;
  width: 232px;
  animation: menuIn 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
  transform-origin: top center;
}
@keyframes menuIn { from { opacity: 0; transform: scale(0.92); } }

.react-row {
  display: flex; gap: 2px; justify-content: space-between;
  padding: 4px 2px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.react-pick {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  padding: 5px; border-radius: 50%;
  transition: transform 0.12s ease, background 0.12s ease;
}
.react-pick:hover { background: var(--bg-hover); transform: scale(1.25); }

.msg-menu-item {
  display: block; width: 100%;
  background: none; border: none;
  color: var(--text); text-align: left;
  font-size: 14px;
  padding: 9px 12px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.12s ease;
}
.msg-menu-item:hover { background: var(--bg-hover); }
.msg-menu-item.danger { color: var(--red); }
.chat-menu { width: 196px; }

/* ---------- Reply / edit bars ---------- */
.reply-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-panel-2);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  animation: fadeIn 0.15s ease both;
}
.reply-bar-body {
  flex: 1;
  border-left: 4px solid var(--green-bright);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: var(--r-sm);
  min-width: 0;
}
.reply-bar-title { font-size: 12px; font-weight: 600; color: var(--green-bright); }
.reply-bar-text {
  font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.edit-bar .reply-bar-title { color: var(--blue); }
.edit-bar .reply-bar-body { border-left-color: var(--blue); }

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}
.input-wrap { flex: 1; }
#msg-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 11px 16px;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.15s ease;
}
#msg-input:focus { border-color: rgba(0, 168, 132, 0.45); }
#msg-input::placeholder { color: var(--text-faint); }

/* ---------- Recorder ---------- */
.recording-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  background: var(--bg-panel-2);
  border-top: 1px solid var(--border);
  z-index: 6;
  animation: fadeIn 0.15s ease both;
}
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--red);
  animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }
#rec-timer { font-size: 15px; font-variant-numeric: tabular-nums; min-width: 44px; }
.rec-actions { margin-left: auto; display: flex; gap: 10px; }
.rec-btn {
  border: none; border-radius: var(--r-full);
  padding: 9px 20px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.rec-btn:active { transform: scale(0.96); }
.rec-cancel { background: var(--bg-hover); color: var(--text); }
.rec-send { background: var(--green); color: #06251d; }
.rec-send:hover { filter: brightness(1.12); }

/* ---------- Floating: jump to latest ---------- */
.scroll-bottom {
  position: absolute;
  right: 22px;
  bottom: 82px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-panel-2);
  color: var(--green-bright);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-2);
  z-index: 5;
  transition: transform 0.12s ease, background 0.15s ease;
}
.scroll-bottom:hover { background: var(--bg-hover); transform: translateY(-2px); }

.load-older {
  align-self: center;
  background: rgba(24, 34, 41, 0.95);
  color: var(--green-bright);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 10px;
  box-shadow: var(--shadow-1);
  transition: background 0.15s ease;
}
.load-older:hover { background: var(--bg-hover); }
.load-older:disabled { color: var(--text-faint); cursor: default; }

/* ============================================================
   Login
   ============================================================ */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 60% at 70% 10%, rgba(0, 168, 132, 0.13), transparent),
    radial-gradient(ellipse 60% 50% at 20% 90%, rgba(83, 189, 235, 0.07), transparent),
    var(--bg-deep);
  padding: 20px;
}
.login-card {
  background: rgba(17, 27, 33, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 44px 38px;
  width: 380px;
  max-width: 94vw;
  text-align: center;
  box-shadow: var(--shadow-3);
  animation: cardIn 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.login-logo { margin-bottom: 12px; }
.login-logo svg { filter: drop-shadow(0 6px 18px rgba(0, 168, 132, 0.35)); }
.login-card h1 { font-size: 23px; font-weight: 600; letter-spacing: 0.2px; margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-card input {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 16px;
  color: var(--text);
  font-size: 14.5px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s ease;
}
.login-card input:focus { border-color: var(--green); }
.login-card button {
  width: 100%;
  background: linear-gradient(180deg, var(--green-bright), var(--green));
  color: #04231b;
  border: none;
  border-radius: var(--r-md);
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  margin-top: 4px;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.login-card button:hover { filter: brightness(1.08); }
.login-card button:active { transform: scale(0.985); }
.login-card button:disabled { opacity: 0.55; cursor: default; }
.login-error { color: var(--red); font-size: 13.5px; margin-top: 12px; min-height: 18px; }

/* ============================================================
   Modals
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 8, 11, 0.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease both;
}
.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 24px;
  width: 430px;
  max-width: 94vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-3);
  animation: modalIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
.modal-wide { width: 580px; }
.modal h3 { font-weight: 600; font-size: 17px; margin-bottom: 14px; letter-spacing: 0.1px; }
.modal h4 { font-weight: 600; font-size: 14px; margin: 8px 0 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin-bottom: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-hint { color: var(--text-muted); font-size: 13.5px; margin: 8px 0 10px; line-height: 1.5; }
.modal input[type="text"], .modal input[type="email"], .modal input[type="password"], .modal select {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}
.modal input:focus, .modal select:focus { border-color: var(--green); }

/* ---------- Buttons ---------- */
.btn {
  border: none;
  border-radius: var(--r-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(180deg, var(--green-bright), var(--green)); color: #04231b; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-hover); color: var(--text); }
.btn-secondary:hover { background: var(--bg-active); }
.btn-danger { background: rgba(241, 92, 109, 0.15); color: var(--red); border: 1px solid rgba(241, 92, 109, 0.4); }
.btn-danger:hover { background: rgba(241, 92, 109, 0.28); }

/* ---------- Attach preview ---------- */
.attach-preview {
  background: var(--bg-panel-2);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  word-break: break-all;
}
.attach-preview img, .attach-preview video { max-width: 100%; max-height: 280px; border-radius: var(--r-sm); }

/* ---------- Admin ---------- */
.admin-tabs { display: flex; gap: 4px; margin: 12px 0 18px; border-bottom: 1px solid var(--border); }
.admin-tab {
  background: none; border: none;
  color: var(--text-muted);
  font-size: 14px; font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: color 0.15s ease;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--green-bright); border-bottom-color: var(--green-bright); }
.admin-tab-content { overflow-x: auto; }

.wa-status-box {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 15px;
  font-size: 14px;
  margin-bottom: 8px;
}
.wa-health {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding: 0 2px;
  min-height: 16px;
}
.wa-health.warn { color: var(--amber); font-weight: 600; }
.qr-box { text-align: center; margin-bottom: 14px; }
.qr-box p { font-size: 13.5px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.qr-box img { background: #fff; padding: 12px; border-radius: var(--r-md); width: 240px; box-shadow: var(--shadow-2); }

.users-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 20px; }
.users-table th {
  text-align: left; color: var(--text-faint); font-weight: 600;
  padding: 8px 6px; border-bottom: 1px solid var(--border);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px;
}
.users-table td { padding: 10px 6px; border-bottom: 1px solid var(--border); }
.users-table .del-user { color: var(--red); background: none; border: none; cursor: pointer; font-size: 13px; }
.users-table .reset-pass { color: var(--blue); background: none; border: none; cursor: pointer; font-size: 13px; margin-right: 8px; }
.users-table .del-user:hover, .users-table .reset-pass:hover { text-decoration: underline; }
.user-actions { white-space: nowrap; }
.admin-ok { color: #7ae0b8; font-size: 13.5px; margin-top: 6px; min-height: 18px; }
.add-user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.add-user-form button { grid-column: span 2; }

/* ---------- Forward / info lists ---------- */
.forward-list { max-height: 320px; overflow-y: auto; margin-top: 10px; }
.forward-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  cursor: pointer;
  border-radius: var(--r-md);
  font-size: 14.5px;
  transition: background 0.12s ease;
}
.forward-item:hover { background: var(--bg-hover); }
.info-line { padding: 9px 4px; font-size: 14px; border-bottom: 1px solid var(--border); }
#forward-search, #newchat-number { margin-top: 4px; }

/* ---------- Toasts ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 12px 20px;
  font-size: 14px;
  z-index: 500;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: var(--shadow-3);
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Labels ---------- */
.label-filter {
  display: flex;
  gap: 6px;
  padding: 2px 12px 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.label-filter::-webkit-scrollbar { height: 5px; }
.label-filter::-webkit-scrollbar-thumb { background: rgba(134, 150, 160, 0.3); border-radius: 3px; }
.label-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.label-chip:hover { background: var(--bg-hover); color: var(--text); }
.label-chip.active {
  background: rgba(0, 168, 132, 0.15);
  border-color: var(--green);
  color: var(--text);
}
.label-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-item-meta { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* Label pills under names (chat list + open-chat header) */
.chat-labels {
  display: flex; gap: 5px;
  margin-top: 5px;
  flex-wrap: wrap;
}
.chat-label-pill {
  display: inline-flex; align-items: center;
  border: 1px solid;
  border-radius: var(--r-full);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 1.5px 8px;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-label-pill.more { color: var(--text-muted); border-color: var(--border-strong); background: var(--bg-panel-2); }
.chat-header-labels { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 3px; }
.chat-header-labels:empty { display: none; }

.labels-list { margin-bottom: 14px; }
.label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.label-toggle {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  padding: 10px 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.label-toggle:hover { background: var(--bg-hover); }
.label-toggle.on { border-color: var(--green); background: rgba(0, 168, 132, 0.1); }
.label-toggle .label-name { flex: 1; }
.label-toggle .label-check { color: var(--green-bright); font-weight: 700; }
.label-delete {
  background: none; border: none;
  color: var(--text-faint);
  font-size: 14px;
  cursor: pointer;
  width: 34px; height: 34px;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease;
}
.label-delete:hover { color: var(--red); background: var(--bg-hover); }
.new-label-row { display: flex; flex-direction: column; gap: 10px; }
.label-colors { display: flex; gap: 8px; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; transform: scale(1.12); }

/* ---------- Assignment ---------- */
.chat-header-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; position: relative; }
.assign-btn {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.assign-btn:hover { background: var(--bg-hover); color: var(--text); }
.assign-btn.assigned { color: var(--green-bright); border-color: rgba(0, 168, 132, 0.5); background: rgba(0, 168, 132, 0.1); }
.assigned-chip {
  border-radius: var(--r-full);
  background: rgba(6, 207, 156, 0.14);
  border: 1px solid rgba(6, 207, 156, 0.35);
  color: var(--green-bright);
  font-size: 11px; font-weight: 600;
  padding: 1px 8px;
  display: inline-flex; align-items: center;
  flex-shrink: 0;
  max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* "By agent" filter dropdown, styled to sit with the filter chips */
.agent-filter {
  flex-shrink: 0;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  color: var(--text-muted);
  font-size: 12.5px; font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
  max-width: 150px;
}
.agent-filter.active { color: var(--green-bright); border-color: rgba(6, 207, 156, 0.5); background: rgba(6, 207, 156, 0.1); }
.agent-filter:focus { outline: none; border-color: var(--accent); }
.agent-filter option { background: var(--bg-panel); color: var(--text); }
.notes-count {
  position: absolute;
  top: 2px; right: 0;
  background: var(--green-bright);
  color: #06251d;
  font-size: 9.5px; font-weight: 700;
  border-radius: var(--r-full);
  padding: 0 4px;
  min-width: 14px;
  line-height: 14px;
}
#notes-btn { position: relative; }

/* ---------- Quick replies ---------- */
.qr-picker {
  position: absolute;
  left: 60px; right: 60px;
  bottom: 66px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  z-index: 8;
  animation: menuIn 0.12s ease both;
}
.qr-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: none; border: none;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
}
.qr-row:hover, .qr-row.active { background: var(--bg-hover); }
.qr-shortcut { color: var(--green-bright); font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.qr-preview { color: var(--text-muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.qr-item { flex: 1; min-width: 0; cursor: pointer; padding: 4px 0; }
.qr-item .qr-preview { white-space: normal; margin-top: 2px; }
.qr-list { max-height: 260px; overflow-y: auto; margin-bottom: 14px; }
.qr-textarea {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  margin-top: 10px;
  transition: border-color 0.15s ease;
}
.qr-textarea:focus { border-color: var(--green); }

/* ---------- Notes ---------- */
.notes-list { max-height: 300px; overflow-y: auto; margin-bottom: 6px; }
.note-row { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 8px; }
.note-body {
  flex: 1;
  background: rgba(255, 210, 121, 0.07);
  border: 1px solid rgba(255, 210, 121, 0.2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.note-text { font-size: 14px; white-space: pre-wrap; }
.note-meta { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }

/* ---------- Auto-reply + scheduling ---------- */
.ar-toggle-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600;
  margin-bottom: 12px;
  cursor: pointer;
}
.ar-toggle-row input { width: 18px; height: 18px; accent-color: var(--green); }
.ar-hours-row { display: flex; gap: 14px; margin: 10px 0; }
.ar-hours-row label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-muted); }
.ar-hours-row select { width: auto; }
#ar-cooldown { width: 90px; }
#tab-autoreply select, #tab-autoreply input[type="number"] {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.schedule-time {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  color-scheme: dark;
}
.schedule-time:focus { border-color: var(--green); }

/* ---------- Reports ---------- */
.reports-toolbar { margin-bottom: 14px; }
.reports-toolbar select {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  width: auto;
}
.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.report-card {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 12px;
  text-align: center;
}
.report-value { font-size: 22px; font-weight: 700; color: var(--green-bright); }
.report-label { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.report-bars { display: flex; align-items: flex-end; gap: 6px; min-height: 90px; margin-bottom: 18px; overflow-x: auto; padding-bottom: 4px; }
.report-bar-col { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }
.report-bar { width: 22px; background: linear-gradient(180deg, var(--green-bright), var(--green-deep)); border-radius: 4px 4px 0 0; }
.report-bar-day { font-size: 9.5px; color: var(--text-faint); }

/* Busy-hours chart (24 hourly bars) */
.report-sub { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.report-hours { display: flex; align-items: flex-end; gap: 3px; height: 74px; margin-bottom: 18px; }
.report-hour-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.report-hour-bar { width: 100%; max-width: 16px; background: linear-gradient(180deg, var(--accent), var(--green-deep)); border-radius: 3px 3px 0 0; }
.report-hour-lbl { font-size: 9px; color: var(--text-faint); white-space: nowrap; }
.report-agent-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); padding-bottom: 6px; }
.report-agent-table th:not(:first-child) { text-align: right; }

/* ---------- Branding (Universal Digital Agency) ---------- */
.login-shell {
  display: flex;
  gap: 0;
  width: 900px;
  max-width: 96vw;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow-3);
  border: 1px solid var(--border-strong);
  animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
.login-brand {
  flex: 1.15;
  background:
    radial-gradient(ellipse 90% 70% at 20% 0%, rgba(6, 207, 156, 0.16), transparent),
    radial-gradient(ellipse 70% 60% at 100% 100%, rgba(6, 147, 227, 0.14), transparent),
    #0d161c;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
}
.brand-mark { margin-bottom: 18px; }
.brand-agency {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: linear-gradient(90deg, #06cf9c, #0693e3);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tagline { color: var(--text); font-size: 15px; margin: 8px 0 24px; line-height: 1.5; }
.brand-points { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.brand-points li {
  color: var(--text-muted);
  font-size: 13.5px;
  padding-left: 26px;
  position: relative;
  line-height: 1.45;
}
.brand-points li::before {
  content: '✓';
  position: absolute; left: 0;
  color: var(--green-bright);
  font-weight: 700;
}
.brand-foot { margin-top: auto; padding-top: 28px; }
.brand-foot a { color: var(--text-faint); font-size: 12.5px; text-decoration: none; letter-spacing: 0.3px; }
.brand-foot a:hover { color: var(--green-bright); }
.login-shell .login-card {
  flex: 1;
  border: none;
  border-radius: 0;
  border-left: 1px solid var(--border);
  box-shadow: none;
  animation: none;
  width: auto;
  max-width: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-powered { color: var(--text-faint); font-size: 12px; margin-top: 22px; }
.login-powered b { color: var(--text-muted); font-weight: 600; }

@media (max-width: 820px) {
  .login-shell { flex-direction: column; width: 440px; }
  .login-brand { padding: 30px 28px 22px; }
  .brand-points { display: none; }
  .brand-foot { display: none; }
  .brand-tagline { margin-bottom: 0; }
  .login-shell .login-card { border-left: none; border-top: 1px solid var(--border); }
}

/* ---------- Ban-risk meter ---------- */
.risk-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 11px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.risk-btn:hover { background: var(--bg-hover); }

/* Generic confirm/prompt dialog */
/* The generic confirm/prompt is often opened from INSIDE another modal
   (admin panel: remove user / reset password, labels modal: delete label).
   It must sit above every other modal-backdrop (all at z-index 100) or it
   renders behind them and looks like the button "did nothing". */
#app-modal { z-index: 600; }
.app-modal { width: 400px; max-width: 92vw; }
.app-modal-message { font-size: 14px; line-height: 1.55; color: var(--text); white-space: pre-line; }
.app-modal-input {
  width: 100%;
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  box-sizing: border-box;
}
.app-modal-input:focus { outline: none; border-color: var(--accent); }

/* Password generator button + field row */
.pw-field { display: flex; gap: 8px; align-items: stretch; }
.pw-field #new-password { flex: 1; }
.pw-gen-btn {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--green-bright);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.pw-gen-btn:hover { background: var(--bg-hover); }
#app-modal-gen { margin-top: 10px; width: 100%; }
/* Account-tab context-menu items (same look as message-menu items) */
.tab-menu-item {
  display: block; width: 100%;
  background: none; border: none;
  color: var(--text); text-align: left;
  font-size: 14px;
  padding: 9px 12px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background 0.12s ease;
}
.tab-menu-item:hover { background: var(--bg-hover); }
.tab-menu-item.danger { color: var(--red); }
.tab-menu-item.danger:hover { background: rgba(241, 92, 109, 0.12); }
.risk-btn.risk-safe { color: var(--green-bright); border-color: rgba(6, 207, 156, 0.45); }
.risk-btn.risk-caution { color: var(--amber); border-color: rgba(255, 210, 121, 0.5); background: rgba(255, 210, 121, 0.08); }
.risk-btn.risk-high { color: var(--red); border-color: rgba(241, 92, 109, 0.55); background: rgba(241, 92, 109, 0.1); animation: riskPulse 1.6s infinite; }
@keyframes riskPulse { 50% { box-shadow: 0 0 0 5px rgba(241, 92, 109, 0.12); } }

.risk-summary {
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.risk-summary.zone-safe { background: rgba(6, 207, 156, 0.08); border-color: rgba(6, 207, 156, 0.3); }
.risk-summary.zone-caution { background: rgba(255, 210, 121, 0.08); border-color: rgba(255, 210, 121, 0.35); }
.risk-summary.zone-high { background: rgba(241, 92, 109, 0.1); border-color: rgba(241, 92, 109, 0.45); }
.risk-score { font-size: 30px; font-weight: 800; letter-spacing: 0.5px; }
.zone-safe .risk-score { color: var(--green-bright); }
.zone-caution .risk-score { color: var(--amber); }
.zone-high .risk-score { color: var(--red); }
.risk-zone-text { font-size: 14px; margin: 6px 0 4px; line-height: 1.5; }

.risk-track { margin-bottom: 18px; }
.risk-zones {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 5px;
}
.risk-bar-outer {
  position: relative;
  height: 12px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg,
    rgba(6, 207, 156, 0.25) 0 40%,
    rgba(255, 210, 121, 0.25) 40% 70%,
    rgba(241, 92, 109, 0.28) 70% 100%);
  overflow: visible;
}
.risk-bar {
  height: 100%;
  border-radius: var(--r-full);
  transition: width 0.5s ease;
}
.risk-bar.zone-safe { background: linear-gradient(90deg, var(--green-bright), var(--green)); }
.risk-bar.zone-caution { background: linear-gradient(90deg, var(--green-bright), var(--amber)); }
.risk-bar.zone-high { background: linear-gradient(90deg, var(--amber), var(--red)); }
.risk-needle {
  position: absolute;
  top: -4px;
  width: 3px; height: 20px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
  transition: left 0.5s ease;
}

.risk-factor {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--r-sm);
  padding: 11px 13px;
  margin-bottom: 8px;
}
.risk-factor.level-safe { border-left-color: var(--green-bright); }
.risk-factor.level-caution { border-left-color: var(--amber); background: rgba(255, 210, 121, 0.05); }
.risk-factor.level-high { border-left-color: var(--red); background: rgba(241, 92, 109, 0.06); }
.rf-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rf-label { font-size: 13.5px; font-weight: 600; }
.rf-value { font-size: 16px; font-weight: 800; }
.level-safe .rf-value { color: var(--green-bright); }
.level-caution .rf-value { color: var(--amber); }
.level-high .rf-value { color: var(--red); }
.rf-limit { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.rf-tip { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.45; }

.risk-guide { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.risk-guide li {
  font-size: 13px; color: var(--text-muted);
  padding-left: 22px; position: relative; line-height: 1.5;
}
.risk-guide li::before { content: '•'; position: absolute; left: 8px; color: var(--green-bright); }

/* ---------- Active ban protection (strip, guard dialog, cold hint) ---------- */
.risk-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  font-size: 12.5px;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}
.risk-strip.zone-caution { background: rgba(255, 210, 121, 0.1); color: var(--amber); }
.risk-strip.zone-high { background: rgba(241, 92, 109, 0.13); color: var(--red); }
.risk-strip-link {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid currentColor;
  border-radius: var(--r-full);
  color: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 11px;
  cursor: pointer;
  flex-shrink: 0;
}
.risk-strip-link:hover { background: rgba(255, 255, 255, 0.16); }

.guard-modal { width: 460px; border-color: rgba(241, 92, 109, 0.4); }
.guard-reason {
  background: rgba(241, 92, 109, 0.1);
  border: 1px solid rgba(241, 92, 109, 0.35);
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 14px;
}
.guard-advice { display: flex; flex-direction: column; gap: 7px; }
.guard-tip { font-size: 13px; color: var(--text-muted); line-height: 1.45; }

.cold-hint {
  padding: 7px 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-panel-2);
  border-top: 1px solid var(--border);
  line-height: 1.4;
}
.cold-hint.risky { color: var(--amber); background: rgba(255, 210, 121, 0.08); }

.back-btn { display: none; }

/* ---------- Accessibility ---------- */
input:focus-visible, textarea:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid rgba(0, 168, 132, 0.55);
  outline-offset: -1px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Touch devices ---------- */
@media (hover: none) {
  .msg-menu-btn { opacity: 1; background: rgba(0, 0, 0, 0.28); }
  .icon-btn { width: 42px; height: 42px; }
  /* The sidebar header packs several icons next to the avatar - keep those a
     bit smaller than the app-wide 42px touch target so the row never overflows
     onto the avatar. */
  .sidebar-actions .icon-btn { width: 38px; height: 38px; }
}

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 760px) {
  #app { height: 100dvh; }
  .back-btn { display: inline-flex; }
  #sidebar { width: 100%; min-width: 0; }
  #sidebar.chat-open { display: none; }
  #main { display: none; }
  #main.chat-open { display: flex; }
  .messages { padding: 14px 3% 10px; }
  .msg { max-width: 88%; }
  .msg-quote-text { max-width: 60vw; }
  #msg-input, .search-wrap input, .login-card input,
  .modal input[type="text"], .modal input[type="email"], .modal input[type="password"], .modal select {
    font-size: 16px;
  }
  .composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); gap: 4px; }
  .sidebar-header { padding: 8px 10px; }
  .chat-header { padding: 8px 10px; gap: 10px; }
  .modal { width: 100%; max-width: 96vw; max-height: 85dvh; padding: 18px; }
  .modal-wide { width: 100%; }
  .add-user-form { grid-template-columns: 1fr; }
  .add-user-form button { grid-column: span 1; }
  .users-table { font-size: 13px; }
  .qr-box img { width: 200px; }
  .scroll-bottom { bottom: calc(82px + env(safe-area-inset-bottom)); right: 14px; }
  .msg-menu { width: 244px; }
  .msg-menu-item { padding: 12px 14px; }
  .react-pick { font-size: 24px; padding: 6px; }
  .attach-preview img, .attach-preview video { max-height: 40vh; }
  .rec-btn { padding: 11px 18px; }
  .qr-picker { left: 8px; right: 8px; bottom: 70px; }
  .assign-btn { max-width: 100px; padding: 6px 10px; font-size: 11.5px; }
}

/* ==================== Tier-2 features ==================== */

/* Modal textareas (new group / broadcast) */
.modal textarea {
  width: 100%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 13px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s ease;
}
.modal textarea:focus { border-color: var(--green); }
.modal textarea::placeholder { color: var(--text-faint); }

/* Small buttons + group management controls */
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn.danger { color: var(--red); }
.group-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.group-participant { justify-content: space-between; }
.group-participant-ctrls { display: flex; gap: 2px; flex-shrink: 0; }
.group-participant-ctrls .icon-btn { width: 30px; height: 30px; font-size: 14px; }
.group-participant-ctrls .icon-btn.danger:hover { color: var(--red); }

/* In-chat search bar */
.chat-search-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.chat-search-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text);
  font-size: 14px;
  padding: 7px 14px;
  outline: none;
}
.chat-search-bar input:focus { border-color: var(--green); }
.chat-search-count {
  font-size: 12.5px; color: var(--text-muted);
  min-width: 62px; text-align: center; white-space: nowrap;
}
.msg.search-hit { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
.msg.search-hit-current { outline: 2px solid var(--green-bright); outline-offset: 2px; }

/* Broadcast */
.broadcast-toolbar { display: flex; align-items: center; gap: 12px; margin: 10px 0 8px; flex-wrap: wrap; }
.broadcast-toolbar input[type="text"] { flex: 1; min-width: 150px; }
.broadcast-selectall {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.broadcast-count { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.broadcast-list {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 4px;
}
.broadcast-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 14.5px;
}
.broadcast-item:hover { background: var(--bg-hover); }
.broadcast-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--green); flex-shrink: 0; }
.broadcast-progress { margin-top: 14px; }
.broadcast-bar { height: 8px; background: var(--bg-input); border-radius: var(--r-full); overflow: hidden; }
.broadcast-bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--green), var(--green-bright));
  transition: width 0.3s ease;
}
.broadcast-status { margin-top: 8px; font-size: 13px; color: var(--text-muted); }

/* @mention picker (group chats) */
.mention-picker { max-height: 260px; overflow-y: auto; }
.mention-row { gap: 10px; }
.mention-av {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.mention-name { font-size: 14.5px; color: var(--text); }

/* Group-info participant rows (avatar + name on the left, controls on the right) */
.group-part-left { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.group-part-name { font-size: 14.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-part-av { width: 36px; height: 36px; font-size: 13px; }

/* Emoji picker */
.emoji-picker {
  position: absolute;
  left: 56px; bottom: 66px;
  width: 322px; max-height: 244px; overflow-y: auto;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  z-index: 9; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  animation: menuIn 0.12s ease both;
}
.emoji-cell {
  background: none; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 5px; border-radius: var(--r-sm);
}
.emoji-cell:hover { background: var(--bg-hover); }

/* Poll modal */
.poll-options { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.poll-option-input { margin: 0; }
.poll-multi { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13.5px; color: var(--text-muted); cursor: pointer; }
.poll-multi input { width: 16px; height: 16px; accent-color: var(--green); }

/* Group invite link */
.group-invite-area { margin: 8px 0; }
.invite-url {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 9px 11px;
  font-size: 13px; color: var(--text); word-break: break-all; margin-bottom: 8px;
}

/* Drag-and-drop a file onto the chat */
.drag-over { outline: 2px dashed var(--green); outline-offset: -8px; }

/* "@ you were mentioned" badge in the chat list */
.mention-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--green); color: #04231b;
  border-radius: var(--r-full); font-size: 12px; font-weight: 800;
  flex-shrink: 0;
}
