:root {
  --brand: #075e54;
  --brand-dark: #054d44;
  --accent: #25d366;
  --accent-dark: #1da851;
  --header-bg: #0b6157;
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --text: #111b21;
  --muted: #667781;
  --line: #e9edef;
  --tick-read: #53bdeb;
  --danger: #e53935;
  --panel: #ffffff;
  --panel-alt: #f0f2f5;
  --shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --radius: 8px;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--panel-alt); color: var(--text); font-size: 14.5px; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: #027eb5; }

/* ------------------------------------------------------------ auth pages */

.auth-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 14px;
  padding: 36px 28px 30px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.auth-card .avatar-lg {
  width: 92px; height: 92px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}
.auth-card h1 { font-size: 22px; font-weight: 500; color: var(--brand); margin: 16px 0 6px; }
.auth-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.auth-card input {
  width: 100%; padding: 14px; border: 2px solid #e1e4e8; border-radius: 10px;
  font-size: 17px; text-align: center; letter-spacing: 1px; outline: none; transition: border-color .15s;
}
.auth-card input + input { margin-top: 10px; }
.auth-card input:focus { border-color: var(--accent); }
.btn-primary {
  display: block; width: 100%; margin-top: 12px; padding: 14px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15.5px; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 20px; margin-top: 12px; }

/* ------------------------------------------------------------ chat shell */

.chat-app { height: 100%; display: flex; flex-direction: column; background: var(--chat-bg); }
.chat-pane { position: relative; display: flex; flex-direction: column; min-height: 0; flex: 1; background: var(--chat-bg); }

.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 60px;
  background: var(--header-bg); color: #fff; flex-shrink: 0; z-index: 2;
}
.chat-header .avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #ddd; flex-shrink: 0; }
.chat-header .who { flex: 1; min-width: 0; }
.chat-header .name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header .status { font-size: 12.5px; opacity: .85; display: flex; align-items: center; gap: 6px; min-height: 16px; }
.chat-header .status .dot { width: 8px; height: 8px; border-radius: 50%; background: #9e9e9e; }
.chat-header .status.online .dot { background: var(--accent); }
.chat-header .actions { display: flex; gap: 8px; align-items: center; }
.chat-header .icon-btn { background: transparent; border: 0; color: #fff; width: 38px; height: 38px; border-radius: 50%; font-size: 17px; }
.chat-header .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.pill-btn {
  border: 0; border-radius: 20px; padding: 8px 14px; font-weight: 600; font-size: 13px;
  background: rgba(255, 255, 255, .15); color: #fff;
}
.pill-btn:hover { background: rgba(255, 255, 255, .25); }
.pill-btn.danger { background: rgba(229, 57, 53, .85); }
.social-links { display: flex; gap: 2px; }
.social-links a { color: #fff; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-size: 17px; }
.social-links a:hover { background: rgba(255, 255, 255, .12); }

.chat-body {
  flex: 1; overflow-y: auto; padding: 14px 6% 10px; min-height: 0;
  background-color: var(--chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23cfc6b8' stroke-width='1.2' opacity='.35'%3E%3Ccircle cx='18' cy='20' r='7'/%3E%3Cpath d='M60 12l6 10H54z'/%3E%3Crect x='92' y='14' width='14' height='12' rx='3'/%3E%3Cpath d='M14 70c4-6 12-6 16 0-4 6-12 6-16 0z'/%3E%3Cpath d='M58 62v14M51 69h14'/%3E%3Cpath d='M92 64c0-5 8-5 8 0 0-5 8-5 8 0 0 6-8 10-8 10s-8-4-8-10z'/%3E%3Ccircle cx='30' cy='104' r='5'/%3E%3Cpath d='M70 100l8 8M78 100l-8 8'/%3E%3Crect x='98' y='98' width='10' height='10' rx='5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 240px 240px;
}
.messages { display: flex; flex-direction: column; gap: 2px; max-width: 920px; margin: 0 auto; }
.load-more { align-self: center; margin: 6px 0 10px; border: 0; background: rgba(255,255,255,.9); color: var(--muted); padding: 6px 14px; border-radius: 14px; font-size: 12.5px; box-shadow: var(--shadow); }

.day-sep { align-self: center; margin: 10px 0; padding: 5px 12px; border-radius: 8px; background: #fff; color: var(--muted); font-size: 12.5px; box-shadow: var(--shadow); }

.msg { display: flex; margin-top: 2px; }
.msg.out { justify-content: flex-end; }
.msg.first { margin-top: 8px; }
.bubble {
  position: relative; max-width: min(78%, 620px); padding: 6px 8px 8px 9px; border-radius: var(--radius);
  background: var(--bubble-in); box-shadow: var(--shadow); word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--bubble-out); }
.msg.first.in .bubble { border-top-left-radius: 0; }
.msg.first.out .bubble { border-top-right-radius: 0; }
.msg.pending .bubble { opacity: .75; }
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 0%, 100% { filter: none; } 30% { filter: brightness(.85); } }

.bubble .agent { font-size: 12px; font-weight: 600; color: #1fa855; margin-bottom: 2px; }
.bubble .text { white-space: pre-wrap; line-height: 1.42; }
.bubble .meta {
  float: right; margin: 6px 0 -4px 12px; font-size: 11px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 4px; position: relative; top: 4px; white-space: nowrap;
}
.bubble .meta .edited { font-style: italic; }
.ticks { font-size: 12px; color: #8696a0; }
.ticks.read { color: var(--tick-read); }
.bubble .menu-btn {
  position: absolute; top: 2px; right: 2px; width: 24px; height: 22px; border: 0; border-radius: 50%;
  background: inherit; color: var(--muted); opacity: 0; transition: opacity .12s; font-size: 12px;
}
.bubble:hover .menu-btn { opacity: 1; }
@media (hover: none) { .bubble .menu-btn { opacity: .55; } }

.bubble .quote {
  display: block; border-left: 4px solid #06cf9c; background: rgba(0, 0, 0, .05); border-radius: 6px;
  padding: 5px 8px; margin-bottom: 5px; font-size: 13px; color: var(--muted); cursor: pointer;
  max-height: 64px; overflow: hidden;
}
.bubble .quote strong { display: block; color: #06cf9c; font-size: 12.5px; }
.bubble .quote.admin { border-color: #7f66ff; }
.bubble .quote.admin strong { color: #7f66ff; }

.bubble .media { display: block; margin: -2px -4px 4px; border-radius: 6px; overflow: hidden; background: #0001; }
.bubble .media img { display: block; max-width: 100%; max-height: 340px; min-width: 120px; cursor: zoom-in; }
.bubble .media video { display: block; max-width: 100%; max-height: 340px; }
.bubble audio { display: block; width: 260px; max-width: 100%; height: 40px; margin: 2px 0; }

.typing-row { max-width: 920px; margin: 8px auto 0; }
.bubble.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.bubble.typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa5ab; animation: blink 1.2s infinite; }
.bubble.typing span:nth-child(2) { animation-delay: .2s; }
.bubble.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.scroll-down {
  position: absolute; right: 18px; bottom: 84px; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: #fff; color: var(--muted); box-shadow: 0 2px 6px rgba(0,0,0,.2); z-index: 3;
}
.scroll-down .badge {
  position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px;
  background: var(--accent); color: #fff; font-size: 11px; line-height: 20px; font-weight: 700;
}
.scroll-down .badge:empty { display: none; }

/* -------------------------------------------------------------- composer */

.compose-ctx {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px 0; background: var(--panel-alt);
}
.compose-ctx .ctx-text {
  flex: 1; min-width: 0; border-left: 4px solid #06cf9c; background: #fff; border-radius: 6px; padding: 6px 10px;
  font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.compose-ctx .ctx-text strong { display: block; color: #06cf9c; font-size: 12.5px; }
.compose-ctx button { border: 0; background: transparent; font-size: 22px; color: var(--muted); width: 32px; height: 32px; }

.upload-progress { position: relative; height: 26px; background: var(--panel-alt); padding: 4px 16px; font-size: 12px; color: var(--muted); }
.upload-progress .bar { position: absolute; left: 0; top: 0; height: 3px; background: var(--accent); width: 0; transition: width .2s; }

.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 8px 12px; background: var(--panel-alt); flex-shrink: 0;
}
.composer-tools { display: flex; }
.composer-tools button, .recorder button.tool {
  width: 40px; height: 44px; border: 0; background: transparent; color: #54656f; font-size: 21px; border-radius: 50%;
}
.composer-tools button:hover { color: var(--brand); }
.input-wrap { flex: 1; min-width: 0; background: #fff; border-radius: 22px; padding: 10px 16px; }
.input-wrap textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent; max-height: 120px; line-height: 1.4; display: block;
}
.round-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 18px; flex-shrink: 0;
}
.round-btn:hover { background: var(--brand-dark); }

.emoji-panel {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; padding: 10px 12px;
  max-height: 220px; overflow-y: auto; background: var(--panel-alt); border-top: 1px solid var(--line);
}
.emoji-panel button { border: 0; background: transparent; font-size: 24px; height: 40px; border-radius: 8px; }
.emoji-panel button:hover { background: #fff; }

.recorder { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel-alt); }
.recorder .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.recorder .rec-time { flex: 1; font-variant-numeric: tabular-nums; color: var(--muted); }
.recorder button.tool { color: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

/* ------------------------------------------------------- menus & modals */

.popover {
  position: fixed; z-index: 50; min-width: 150px; background: #fff; border-radius: 8px; padding: 6px 0;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.popover button { display: flex; gap: 12px; align-items: center; width: 100%; border: 0; background: none; padding: 9px 18px; text-align: left; color: var(--text); }
.popover button:hover { background: var(--panel-alt); }
.popover button i { width: 16px; color: var(--muted); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(11, 20, 26, .85);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; padding: 18px; }
.modal-card h3 { margin: 0 0 12px; font-weight: 500; }
.modal-card .preview { max-height: 55vh; display: flex; justify-content: center; background: #f4f4f4; border-radius: 8px; overflow: hidden; }
.modal-card .preview img, .modal-card .preview video { max-width: 100%; max-height: 55vh; }
.modal-card .row { display: flex; gap: 10px; margin-top: 12px; }
.modal-card .row input { flex: 1; padding: 11px 14px; border: 1px solid #d1d7db; border-radius: 22px; outline: none; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 4px; }
.lightbox .close { position: fixed; top: 14px; right: 18px; border: 0; background: none; color: #fff; font-size: 30px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60; background: #323232; color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: 90vw;
}
.toast.error { background: #c62828; }

.offline-bar { background: #fff3cd; color: #7a5b00; text-align: center; font-size: 12.5px; padding: 4px; }

/* ----------------------------------------------------------- admin panel */

.admin-app { height: 100%; display: grid; grid-template-columns: 380px 1fr; background: var(--panel); }
.sidebar { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: #fff; }
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-height: 60px; background: var(--panel-alt); }
.sidebar-head .me { flex: 1; font-weight: 600; }
.sidebar-head .me small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.sidebar-head a, .sidebar-head button { border: 0; background: none; color: #54656f; font-size: 18px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; }
.sidebar-head a:hover, .sidebar-head button:hover { background: #e2e5e8; }
.search { padding: 8px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.search input { flex: 1; border: 0; background: var(--panel-alt); border-radius: 8px; padding: 9px 14px; outline: none; }
.search select { border: 0; background: var(--panel-alt); border-radius: 8px; padding: 0 8px; }
.conv-list { flex: 1; overflow-y: auto; }
.conv {
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.conv:hover { background: #f5f6f6; }
.conv.active { background: #e9edef; }
.conv .av, .letter-av {
  width: 46px; height: 46px; border-radius: 50%; background: #dfe5e7; color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 17px; flex-shrink: 0; position: relative;
}
.chat-header .letter-av { width: 42px; height: 42px; }
.conv .av .on { position: absolute; right: 0; bottom: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.conv .body { flex: 1; min-width: 0; }
.conv .line1, .conv .line2 { display: flex; align-items: center; gap: 8px; }
.conv .title { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { font-size: 12px; color: var(--muted); }
.conv.unread .time { color: var(--accent-dark); font-weight: 600; }
.conv .preview { flex: 1; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .preview.typing { color: var(--accent-dark); font-style: italic; }
.conv .count { min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center; }
.conv .tag { font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: #fdecea; color: var(--danger); font-weight: 600; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; padding: 24px; background: var(--panel-alt); }
.empty-state i { font-size: 54px; margin-bottom: 14px; color: #c5ccd0; }
.list-empty { padding: 30px 16px; text-align: center; color: var(--muted); }
.back-btn { display: none !important; }

@media (max-width: 820px) {
  .admin-app { grid-template-columns: 1fr; }
  .admin-app .main { display: none; }
  .admin-app.show-chat .sidebar { display: none; }
  .admin-app.show-chat .main { display: flex; }
  .back-btn { display: grid !important; }
}
.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }

/* -------------------------------------------------------- settings page */

.settings-page { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
.settings-page .top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.settings-page .top h1 { flex: 1; font-size: 22px; font-weight: 500; margin: 0; }
.card { background: #fff; border-radius: 12px; padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h2 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: #3b4a54; margin-bottom: 6px; }
.field input[type=text], .field input[type=url], .field input[type=password], .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d7db; border-radius: 8px; outline: none; background: #fff;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.avatar-row { display: flex; align-items: center; gap: 16px; }
.avatar-row img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); }
.btn { border: 0; border-radius: 8px; padding: 10px 18px; background: var(--brand); color: #fff; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--brand-dark); }
.btn.light { background: var(--panel-alt); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.list th { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
table.list td.actions { white-space: nowrap; text-align: right; }
table.list td.actions .btn { margin-left: 4px; }
.table-wrap { overflow-x: auto; }
.badge-role { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #e7f8ee; color: #1a7f45; font-weight: 600; }
.badge-off { background: #fdecea; color: var(--danger); }

@media (max-width: 600px) {
  .chat-body { padding: 10px 8px; }
  .bubble { max-width: 88%; }
  .chat-header { padding: 8px 10px; gap: 10px; }
  .social-links { display: none; }
}

/* -------------------------------------------------------------- stickers */

.bubble.sticker { background: transparent !important; box-shadow: none; padding: 0; }
.bubble.sticker .sticker-img { display: block; width: 140px; height: 140px; object-fit: contain; }
.bubble.sticker .quote { background: #fff; }
.bubble.sticker .meta {
  float: none; position: static; display: inline-flex; margin: 2px 0 0; padding: 1px 8px;
  border-radius: 10px; background: rgba(255, 255, 255, .85);
}
.msg.out .bubble.sticker { text-align: right; }

.sticker-panel {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; padding: 10px 12px;
  max-height: 240px; overflow-y: auto; background: var(--panel-alt); border-top: 1px solid var(--line);
}
.sticker-panel button { border: 0; background: transparent; border-radius: 10px; padding: 4px; aspect-ratio: 1; }
.sticker-panel button:hover { background: #fff; }
.sticker-panel img { width: 100%; height: 100%; object-fit: contain; }
.sticker-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 18px; }

.sticker-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.sticker-tile { position: relative; background: var(--panel-alt); border-radius: 10px; padding: 8px; aspect-ratio: 1; }
.sticker-tile img { width: 100%; height: 100%; object-fit: contain; }
.sticker-tile button {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: var(--danger); color: #fff; font-size: 16px; line-height: 1; opacity: 0; transition: opacity .12s;
}
.sticker-tile:hover button { opacity: 1; }
@media (hover: none) { .sticker-tile button { opacity: 1; } }

/* ------------------------------------------------------------- call logs */

.bubble.call-log { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-width: 210px; }
.call-log .call-icon {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 168, 132, .12); color: #00a884; flex-shrink: 0;
}
.call-log.missed .call-icon { background: rgba(229, 57, 53, .1); color: var(--danger); }
.call-log .call-text { flex: 1; font-weight: 500; }
.call-log .call-text small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.call-log .meta { float: none; position: static; margin: 0; align-self: flex-end; }

/* ----------------------------------------------------------- call screen */

.pill-btn.call { background: var(--accent); }
.pill-btn.call:hover { background: var(--accent-dark); }

.call-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(7, 37, 33, .78); backdrop-filter: blur(4px);
}
.call-card {
  width: 100%; max-width: 340px; border-radius: 22px; padding: 34px 24px 28px; text-align: center; color: #fff;
  background: linear-gradient(160deg, #0b6157 0%, #073b35 100%); box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}
.call-avatar { width: 104px; height: 104px; margin: 0 auto 16px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: rgba(255,255,255,.12); font-size: 42px; }
.call-avatar img { width: 100%; height: 100%; object-fit: cover; }
.call-avatar .call-letter { width: 100%; height: 100%; display: grid; place-items: center; }
.call-overlay[data-mode="incoming"] .call-avatar, .call-overlay[data-mode="outgoing"] .call-avatar { animation: callpulse 1.6s infinite; }
@keyframes callpulse { 0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .55); } 100% { box-shadow: 0 0 0 26px rgba(37, 211, 102, 0); } }
.call-name { font-size: 20px; font-weight: 600; word-break: break-word; }
.call-status { margin-top: 6px; opacity: .8; font-variant-numeric: tabular-nums; min-height: 20px; }
.call-actions { display: flex; justify-content: center; gap: 26px; margin-top: 32px; }
.call-btn { width: 62px; height: 62px; border-radius: 50%; border: 0; color: #fff; font-size: 22px; }
.call-btn.accept { background: var(--accent); animation: callpulse 1.6s infinite; }
.call-btn.decline, .call-btn.hangup { background: var(--danger); }
.call-btn.mute { background: rgba(255, 255, 255, .16); }
.call-btn.mute.on { background: #fff; color: var(--brand); }

/* Admin: mobile number on top, username underneath */
.conv .subname { font-size: 12px; color: var(--muted); margin: 1px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .title { font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.call-sub { margin-top: 2px; font-size: 14px; opacity: .75; }

/* Admin: date filter + export */
.date-filter {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.date-filter input[type=date] {
  flex: 1; min-width: 0; border: 0; background: var(--panel-alt); border-radius: 8px; padding: 7px 8px; outline: none; font-size: 13px;
}
.date-filter input[type=date]:focus { box-shadow: 0 0 0 2px var(--accent); }
.df-btn {
  flex-shrink: 0; width: 34px; height: 34px; border: 0; border-radius: 8px; background: var(--panel-alt); color: #54656f;
  display: grid; place-items: center;
}
.df-btn:hover { background: #e2e5e8; }
.df-btn.export { background: var(--brand); color: #fff; }
.df-btn.export:hover { background: var(--brand-dark); }
.filter-summary { padding: 7px 14px; background: #e7f8ee; color: #1a7f45; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------- social page */

body.social-body {
  min-height: 100%; color: #fff; background-color: #0b0b0f;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(233, 30, 99, .18) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(66, 133, 244, .18) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(37, 211, 102, .10) 0%, transparent 55%);
  background-attachment: fixed;
}
.social-page { max-width: 480px; margin: 0 auto; padding: 32px 16px 110px; text-align: center; }
.social-avatar {
  width: 104px; height: 104px; border-radius: 50%; object-fit: cover; border: 3px solid rgba(255, 255, 255, .12);
  box-shadow: 0 0 0 4px rgba(233, 30, 99, .25), 0 0 34px rgba(233, 30, 99, .45);
}
.social-page h1 {
  margin: 18px 0 6px; font-size: 26px; font-weight: 800; letter-spacing: .2px;
  background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.social-sub { margin: 0 0 30px; color: rgba(255, 255, 255, .6); font-size: 14px; font-weight: 600; }
.social-note {
  display: inline-flex; gap: 8px; align-items: center; margin: -12px 0 22px; padding: 7px 14px; border-radius: 20px;
  background: rgba(37, 211, 102, .14); color: #6ee7a8; font-size: 13px; font-weight: 600;
}
.social-links-list { display: flex; flex-direction: column; gap: 14px; }
.social-card {
  --c1: #25d366; --c2: #128c7e;
  position: relative; display: flex; align-items: center; gap: 16px; padding: 18px 20px 18px 22px; text-align: left;
  border-radius: 18px; border: 1px solid rgba(255, 255, 255, .09); background: rgba(255, 255, 255, .055);
  color: #fff; text-decoration: none; overflow: hidden; transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.social-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(var(--c1), var(--c2)); }
.social-card:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .09); border-color: rgba(255, 255, 255, .16); }
.social-card.telegram { --c1: #2aabee; --c2: #0077b5; }
.social-card.instagram { --c1: #f58529; --c2: #dd2a7b; }
.social-card.website { --c1: #4285f4; --c2: #34a853; }
.social-card.apk { --c1: #a78bfa; --c2: #6d28d9; }
.social-icon {
  width: 54px; height: 54px; border-radius: 14px; flex-shrink: 0; display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
}
.social-text { flex: 1; min-width: 0; }
.social-text strong { display: block; font-size: 16px; }
.social-text small { display: block; margin-top: 3px; color: rgba(255, 255, 255, .6); font-size: 13px; }
.social-arrow { color: rgba(255, 255, 255, .45); }
.social-empty { color: rgba(255, 255, 255, .55); }
.social-footer { margin-top: 44px; padding-top: 24px; border-top: 1px solid rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .45); font-size: 12px; }
.social-footer .fa-heart { color: #e91e63; margin: 0 4px; }

.chat-fab { position: fixed; right: 16px; bottom: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; z-index: 20; }
.chat-fab-bubble {
  position: relative; padding: 9px 14px; border-radius: 18px; background: #fff; color: #222; text-decoration: none;
  font-size: 13.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); animation: fabFloat 3s ease-in-out infinite;
}
.chat-fab-bubble b { color: #128c7e; }
.chat-fab-bubble::after {
  content: ""; position: absolute; right: 26px; bottom: -6px; width: 12px; height: 12px; background: #fff; transform: rotate(45deg);
}
.chat-fab-btn {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: #128c7e; color: #fff;
  font-size: 26px; text-decoration: none; box-shadow: 0 8px 24px rgba(18, 140, 126, .5);
}
.chat-fab-btn:hover { background: #0e7366; }
@keyframes fabFloat { 50% { transform: translateY(-4px); } }

/* ------------------------------------------------------- categories */

.cat-tag { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 8px; font-size: 10.5px; font-weight: 700; line-height: 17px; vertical-align: 1px; }
.cat-tag.responsive { background: #e7f8ee; color: #1a7f45; }
.cat-tag.non_responsive { background: #fdecea; color: #c62828; }
.conv .subname:empty { display: none; }

.cat-select {
  border: 1px solid #d1d7db; border-radius: 8px; padding: 6px 8px; font-size: 13px; font-weight: 600; background: #fff; color: var(--text);
}
.cat-select.responsive { border-color: #9be2b8; background: #e7f8ee; color: #1a7f45; }
.cat-select.non_responsive { border-color: #f5b5b0; background: #fdecea; color: #c62828; }
.cat-select.header { border-radius: 20px; padding: 7px 10px; max-width: 150px; }
.cat-select.header.none { background: rgba(255, 255, 255, .15); border-color: transparent; color: #fff; }
.cat-select.header.none option { color: var(--text); }

@media (max-width: 600px) {
  .chat-header .pill-btn .lbl { display: none; }
  .chat-header .pill-btn { padding: 8px 11px; }
  .cat-select.header { max-width: 118px; font-size: 12px; padding: 6px 6px; }
}

/* ------------------------------------------------------- report page */

.report-page { max-width: 1180px; }
.report-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.report-filters .field { margin: 0; min-width: 140px; }
.report-filters .field.grow { flex: 1; min-width: 180px; }
.report-filters select, .report-filters input {
  width: 100%; padding: 9px 10px; border: 1px solid #d1d7db; border-radius: 8px; background: #fff; outline: none;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip {
  border: 1px solid #d1d7db; background: #fff; border-radius: 20px; padding: 7px 14px; font-size: 13px; color: var(--text);
}
.chip b { margin-left: 4px; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.responsive:not(.active) b { color: #1a7f45; }
.chip.non_responsive:not(.active) b { color: #c62828; }
.report-table td small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.report-table .num { text-align: right; }
.report-table td.empty { text-align: center; color: var(--muted); padding: 30px; }
.mobile-link { font-weight: 600; color: var(--text); text-decoration: none; }
.mobile-link:hover { color: var(--brand); text-decoration: underline; }
.report-page .top .btn { white-space: nowrap; }

/* ------------------------------------------------------ quick replies */

.quick-panel { max-height: 300px; overflow-y: auto; background: var(--panel-alt); border-top: 1px solid var(--line); padding: 8px 12px 12px; }
.qp-section + .qp-section { margin-top: 10px; }
.qp-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin: 4px 2px 6px; }
.qp-head i { margin-right: 4px; }
.qp-empty { font-size: 13px; color: var(--muted); padding: 6px 2px; }
.qp-text {
  display: block; width: 100%; text-align: left; border: 0; background: #fff; border-radius: 10px; padding: 8px 12px; margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.qp-text:hover { background: #f0fdf4; }
.qp-text strong { display: block; font-size: 13.5px; }
.qp-text span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qp-audio { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 10px; padding: 6px 8px; margin-bottom: 6px; box-shadow: var(--shadow); }
.qp-play { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--panel-alt); color: var(--brand); flex-shrink: 0; }
.qp-play:hover { background: #e2e5e8; }
.qp-title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qp-send { border: 0; border-radius: 16px; padding: 6px 12px; background: var(--brand); color: #fff; font-size: 12.5px; font-weight: 600; flex-shrink: 0; }
.qp-send:hover { background: var(--brand-dark); }
.qp-send:disabled { opacity: .6; }

.sub-h { font-size: 14px; margin: 18px 0 10px; color: #3b4a54; }
.q-count { font-weight: 600; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e7f8ee; color: #1a7f45; margin-left: 6px; }
.q-count.full { background: #fdecea; color: var(--danger); }
.q-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.q-item { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.q-main { flex: 1; min-width: 0; }
.q-main strong { display: block; }
.q-body { display: block; color: var(--muted); font-size: 13px; white-space: pre-wrap; max-height: 3.9em; overflow: hidden; }
.q-main audio { display: block; margin-top: 6px; height: 34px; width: 100%; max-width: 360px; }
.q-actions { display: flex; gap: 6px; flex-shrink: 0; }
.q-form { padding: 12px; background: var(--panel-alt); border-radius: 10px; }
.q-form .field textarea { min-height: 80px; }
.q-form .btn:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 600px) {
  .q-item { flex-direction: column; align-items: stretch; }
}

/* Quick replies: images */
.qp-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.qp-image { display: flex; flex-direction: column; gap: 6px; background: #fff; border-radius: 10px; padding: 6px; box-shadow: var(--shadow); }
.qp-thumb { border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--panel-alt); aspect-ratio: 4 / 3; cursor: zoom-in; }
.qp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qp-image .qp-title { padding: 0 2px; font-size: 13px; }
.qp-image .qp-send { align-self: stretch; }

.q-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.q-image { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.q-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: var(--panel-alt); }
.q-caption { font-size: 12.5px; color: var(--muted); }
.q-image .q-actions { flex-wrap: wrap; }
