:root {
  font-family: Inter, system-ui, sans-serif;
  --bg-1: #eef3ff;
  --bg-2: #f7f9ff;
  --panel: #ffffff;
  --text-main: #111827;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --border: #e5e7eb;
  --success-soft: #dcfce7;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow-soft: 0 12px 30px rgba(37, 99, 235, 0.12);
  --shadow-strong: 0 18px 40px rgba(15, 23, 42, 0.22);
}

:root.theme-dark {
  --bg-1: #0b1220;
  --bg-2: #0f172a;
  --panel: #111827;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --primary: #60a5fa;
  --primary-soft: #1e3a8a;
  --border: #334155;
  --success-soft: #14532d;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, var(--bg-1), var(--bg-2));
  color: var(--text-main);

  overscroll-behavior: none;
}

.app {
  max-width: 1240px;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + var(--safe-top)) 12px calc(10px + var(--safe-bottom));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;

}

.app-version {
  position: fixed;
  right: 10px;
  top: 10px;
  z-index: 60;
  font-size: 11px;
  color: #fff;
  background: rgba(17, 24, 39, 0.85);
  border-radius: 999px;
  padding: 4px 8px;
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 20;
  pointer-events: none;
}

.card {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

.hidden {
  display: none !important;
}

.auth {
  max-width: 400px;
  margin: 80px auto;
  padding: 24px;
}

input,
textarea,
button,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  transition: all 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
}

button.secondary {
  background: #6b7280;
}

button.danger {
  background: #b91c1c;
}

button.ghost {
  background: #e5edff;
  color: #1d4ed8;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.row {
  display: flex;
  gap: 8px;
}

.chat {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.sidebar,
.dialog {
  min-height: 0;
  height: 100%;
  padding: 14px;
  box-sizing: border-box;
}

.sidebar {
  border: 1px solid color-mix(in srgb, var(--border) 70%, #fff 30%);
}

.dialog {
  border: 1px solid color-mix(in srgb, var(--border) 75%, #fff 25%);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;

}

.dialog {
  display: flex;
  flex-direction: column;

}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tab {
  background: #eef2ff;
  color: #111827;
  font-weight: 600;
}

.tab.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
}

.sidebar-header {
  display: flex;
  gap: 6px;
  align-items: center;
  background: #f8faff;
  border-radius: 10px;
  padding: 8px;
}

.sidebar-header strong {
  flex: 1;
  min-width: 0;
  white-space: nowrap;

}

.actions-wrap button {
  width: 100%;
  margin-bottom: 6px;
}

.results,
.conversations,
.chips {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  background: #fafcff;
  margin-bottom: 8px;

}

.conversations {
  flex: 1;
  max-height: none;
}

.results {
  max-height: 32vh;
}

.chips {
  max-height: 110px;
}

.search-item,
.conv-item {
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: #eef2ff;
  border: 1px solid rgba(99, 102, 241, 0.08);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conv-item {
  cursor: pointer;
}

.search-item:hover,
.conv-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.1);
}

.conv-item.active {
  background: var(--primary-soft);
  border-color: rgba(37, 99, 235, 0.28);
}

.conv-item .muted {
  white-space: nowrap;

}

.search-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.support-btn {
  width: 100%;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.back-btn {
  margin-bottom: 8px;
}

.badge {
  background: #e5e7eb;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.messages {
  flex: 1;

  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, #fbfdff, #f8fbff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.msg {
  background: #edf2ff;
  border-radius: 12px;
  padding: 9px;
  margin-bottom: 8px;
  border: 1px solid rgba(37, 99, 235, 0.1);
  animation: fade-up 0.18s ease;
}

.msg.my {
  background: var(--success-soft);
  border-color: rgba(16, 185, 129, 0.18);
}

.msg .meta {
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 4px;
}

.msg img,
.msg video,
.media-preview img,
.media-preview video {
  max-width: min(320px, 100%);
  border-radius: 8px;
  display: block;
  margin-top: 8px;
}

.msg img,
.msg video {
  cursor: zoom-in;
}

.media-full-btn {
  margin-top: 8px;
}

.composer {
  margin-top: 8px;
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.composer textarea {
  min-height: 64px;
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.media-preview {
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
  background: #fff;
}

.support-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.support-actions button {
  background: #f59e0b;
  color: #111827;
  padding: 6px 8px;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-card {
  width: min(620px, 94vw);
  max-height: 86vh;

  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.28);
}

.media-viewer-card {
  width: min(960px, 98vw);
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.media-viewer-close {
  align-self: flex-end;
}

.media-viewer-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58vh;
}

.media-viewer-body img,
.media-viewer-body video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
}

.ui-row {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  background: #dbeafe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #1e3a8a;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.toast-container {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
}

.toast {
  background: #111827;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  max-width: min(86vw, 420px);
  font-size: 13px;
}

.messages::-webkit-scrollbar,
.conversations::-webkit-scrollbar,
.results::-webkit-scrollbar,
.chips::-webkit-scrollbar,
.modal-card::-webkit-scrollbar {
  width: 9px;
}

.messages::-webkit-scrollbar-thumb,
.conversations::-webkit-scrollbar-thumb,
.results::-webkit-scrollbar-thumb,
.chips::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--primary) 45%, #94a3b8 55%);
  border-radius: 999px;
}

.messages::-webkit-scrollbar-track,
.conversations::-webkit-scrollbar-track,
.results::-webkit-scrollbar-track,
.chips::-webkit-scrollbar-track,
.modal-card::-webkit-scrollbar-track {
  background: transparent;
}

.toast.hide {
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s ease;
}

.compact-ui .sidebar,
.compact-ui .dialog {
  padding: 10px;
}

.compact-ui .msg {
  padding: 7px;
  margin-bottom: 6px;
}

.compact-ui button {
  padding: 8px 10px;
}

@media (max-width: 980px) {
  .chat {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app {
    padding: var(--safe-top) 0 var(--safe-bottom);
  }

  .app-footer {
    display: none;
  }

  .card {
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }

  .chat {
    gap: 0;
    grid-template-columns: 1fr;
  }

  .sidebar,
  .dialog {
    height: 100%;
    padding: 10px 12px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--panel);
    padding-bottom: 8px;
  }

  .tab {
    min-height: 44px;
  }

  .sidebar-header {
    gap: 8px;
    padding: 10px;
  }

  .sidebar-header button {
    min-height: 42px;
  }

  .chat:not(.dialog-only) .dialog {
    display: none;
  }

  .chat.dialog-only .sidebar {
    display: none;
  }

  .chat.dialog-only .dialog {
    display: flex;
  }

  .dialog {
    padding-bottom: calc(12px + var(--safe-bottom));
  }

  .dialog-header h2 {
    margin-top: 2px;
    margin-bottom: 4px;
    font-size: 20px;
  }

  .messages {
    border-radius: 14px;
  }

  .composer {
    position: sticky;
    bottom: 0;
    background: color-mix(in srgb, var(--panel) 90%, white 10%);
    border-radius: 14px;
    margin-top: 10px;
  }

  .composer textarea {
    min-height: 56px;
  }

  .composer-row,
  .row,
  .sidebar-header {
    flex-wrap: wrap;
  }

  .composer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-wrap button,
  .support-btn,
  .back-btn {
    min-height: 44px;
  }

  .conversations,
  .results {
    border-radius: 12px;
  }

  .conv-item,
  .search-item {
    padding: 10px;
  }

  .toast-container {
    left: 8px;
    right: 8px;
    bottom: calc(8px + var(--safe-bottom));
  }

  .app-version {
    top: calc(4px + var(--safe-top));
    right: 6px;
    font-size: 10px;
    padding: 3px 7px;
    opacity: 0.85;
  }
}

:root.theme-dark body {
  background: radial-gradient(circle at top left, #0b1220, #111827);
}

:root.theme-dark .card,
:root.theme-dark .modal-card {
  border-color: #334155;
}

:root.theme-dark input,
:root.theme-dark textarea,
:root.theme-dark select {
  background: #0f172a;
  color: #e5e7eb;
  border-color: #334155;
}

:root.theme-dark .search-item,
:root.theme-dark .conv-item,
:root.theme-dark .sidebar-header,
:root.theme-dark .messages,
:root.theme-dark .composer,
:root.theme-dark .results,
:root.theme-dark .conversations,
:root.theme-dark .chips {
  background: #0f172a;
  border-color: #334155;
}

:root.theme-dark .msg {
  background: #1e293b;
  border-color: #334155;
}

:root.theme-dark .msg.my {
  background: #14532d;
}


.auth-switch {
  margin-bottom: 8px;
}

.auth-page textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

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

.call-modal-card {
  width: min(900px, 96vw);
}

.call-videos {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
  margin: 10px 0;
}

.call-videos video {
  width: 100%;
  border-radius: 12px;
  background: #0f172a;
  min-height: 160px;
}

#remoteVideo {
  min-height: 300px;
}

@media (max-width: 700px) {
  .call-videos {
    grid-template-columns: 1fr;
  }

  #remoteVideo {
    min-height: 220px;
  }
}


.mobile-topbar { display:none; }
.icon-btn { min-width:44px; min-height:44px; border-radius:14px; font-size:18px; padding:0; }
.drawer-close-btn { display:none; }
.side-drawer { transition: transform .22s ease, opacity .22s ease; }
.conv-item__row, .search-item__left { display:flex; align-items:center; gap:10px; min-width:0; }
.conv-item__body, .search-item__body { min-width:0; flex:1; }
.conv-item__title-row { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.conv-item__title-row strong, .search-item__body strong, .search-item__body div:first-child { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.status-dot { width:10px; height:10px; border-radius:999px; display:inline-block; flex:0 0 auto; box-shadow:0 0 0 3px rgba(255,255,255,.9); background:#e5e7eb; }
.status-dot.online { background:#22c55e; }
.avatar-wrap { position:relative; display:inline-flex; }
.avatar-wrap .status-dot { position:absolute; right:-1px; bottom:-1px; }
.call-overlay {
  position:fixed; inset:0; z-index:120; background:rgba(10,15,28,.55);
  display:flex; align-items:center; justify-content:center;
  padding:max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)) 14px;
  box-sizing:border-box;
}
.call-shell {
  width:min(520px,100%); max-height:calc(100dvh - 24px);
  background:linear-gradient(180deg,#ffffff,#f6f9ff); color:#111827;
  border-radius:28px; box-shadow:0 30px 80px rgba(15,23,42,.35);
  overflow:hidden; display:flex; flex-direction:column;
}
.call-shell__header { display:flex; align-items:center; justify-content:space-between; padding:16px 18px 10px; gap:10px; }
.call-shell__person { display:flex; gap:12px; align-items:center; min-width:0; }
.call-shell__person strong { display:block; font-size:18px; }
.call-avatar { width:48px; height:48px; border-radius:999px; background:linear-gradient(135deg,#2563eb,#60a5fa); color:#fff; display:grid; place-items:center; font-weight:700; }
.call-close-btn { min-width:42px; min-height:42px; border-radius:999px; font-size:18px; }
.call-stage { position:relative; padding:0 14px 14px; }
.call-stage video { display:block; width:100%; border-radius:20px; background:#0f172a; object-fit:cover; }
#remoteVideo { aspect-ratio:4 / 5; max-height:54vh; }
#localVideo { position:absolute; right:24px; bottom:24px; width:110px; aspect-ratio:3 / 4; border:2px solid rgba(255,255,255,.9); box-shadow:0 10px 24px rgba(0,0,0,.2); }
.incoming-call-badge { position:absolute; left:26px; top:18px; background:rgba(17,24,39,.82); color:#fff; border-radius:999px; padding:8px 12px; font-size:12px; }
.call-actions-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; padding:0 14px 16px; }
.call-action { min-height:48px; border-radius:16px; font-weight:700; }
.call-action.accept { background:#16a34a; }
.call-action.reject { background:#f59e0b; }
.call-action.end { background:#dc2626; }

@media (max-width:980px) {
  .mobile-topbar {
    position:sticky; top:0; z-index:90; display:flex; align-items:center; justify-content:space-between;
    padding:calc(8px + env(safe-area-inset-top)) 12px 8px; background:rgba(255,255,255,.86);
    backdrop-filter:blur(16px); border-bottom:1px solid rgba(148,163,184,.2);
  }
  .mobile-topbar__left { display:flex; align-items:center; gap:10px; }
  .mobile-brand { display:flex; flex-direction:column; gap:2px; }
  .app { padding-top:8px; }
  .sidebar {
    position:fixed; right:0; top:0; bottom:0; width:min(420px, 92vw); z-index:100;
    border-radius:20px 0 0 20px; transform:translateX(104%); opacity:0; overflow:auto;
    padding-top:calc(16px + env(safe-area-inset-top));
  }
  body.drawer-open .sidebar { transform:translateX(0); opacity:1; }
  body.drawer-open::before { content:""; position:fixed; inset:0; background:rgba(15,23,42,.36); z-index:95; }
  .drawer-close-btn { display:inline-flex; align-items:center; justify-content:center; }
  .chat { display:block; }
  .dialog { height:calc(100dvh - 76px - env(safe-area-inset-bottom)); border-radius:24px 24px 0 0; margin-top:6px; }
  .app-footer { position:static; text-align:center; padding:8px 0 2px; margin-bottom:calc(4px + env(safe-area-inset-bottom)); }
}
@media (max-width:700px) {
  .app { height:auto; min-height:calc(100dvh - 60px); padding:8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .dialog { height:calc(100dvh - 90px - env(safe-area-inset-bottom)); padding:10px; }
  .call-shell { border-radius:22px; }
  .call-shell__header { padding:14px 14px 8px; }
  .call-stage { padding:0 10px 12px; }
  #remoteVideo { aspect-ratio:9 / 13; max-height:50vh; }
  #localVideo { width:92px; right:18px; bottom:18px; }
  .call-actions-grid { grid-template-columns:1fr; }
}


/* v1.7.2 fixes */
@media (max-width:980px) {
  body.drawer-open .chat.dialog-only .sidebar,
  body.drawer-open .chat .sidebar {
    display:flex !important;
  }

  body.drawer-open .sidebar {
    right:0;
    left:auto;
    max-width:min(420px, 92vw);
  }
}

.call-stage {
  min-height: 220px;
}

.call-stage video {
  pointer-events: none;
}

#remoteVideo {
  width: 100%;
  height: min(52vh, 420px);
  max-height: 52vh;
  object-fit: cover;
}

#localVideo {
  z-index: 2;
}

.call-actions-grid {
  position: relative;
  z-index: 3;
}

.app-footer {
  max-width: 100%;
  text-align: center;
  line-height: 1.35;
  padding-left: 12px;
  padding-right: 12px;
  word-break: break-word;
}

.debug-console {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 140;
  background: rgba(3, 7, 18, 0.92);
  color: #d1fae5;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0,0,0,0.32);
}

.debug-console summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 700;
  user-select: none;
}

.debug-console__actions {
  padding: 0 12px 8px;
}

.debug-console pre {
  margin: 0;
  padding: 0 12px 12px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width:700px) {
  #remoteVideo {
    height: min(44vh, 340px);
    max-height: 44vh;
  }

  .app-footer {
    font-size: 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .debug-console {
    left: 8px;
    right: 8px;
  }

  .debug-console pre {
    max-height: 130px;
  }
}


/* v1.7.3 debug + calls */
.debug-toggle-btn {
  position: fixed;
  right: 10px;
  top: calc(10px + env(safe-area-inset-top));
  z-index: 141;
  min-width: 52px;
  min-height: 38px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}
.debug-console {
  left: auto;
  right: 10px;
  top: calc(56px + env(safe-area-inset-top));
  bottom: auto;
  width: min(420px, calc(100vw - 20px));
  max-height: min(46vh, 360px);
  z-index: 141;
}
.debug-console__header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 10px 12px 0;
}
.debug-console__header strong {
  color:#f8fafc;
}
.debug-console.hidden,
.debug-toggle-btn.hidden {
  display:none !important;
}
.debug-console pre {
  max-height: min(34vh, 250px);
}
@media (max-width:700px) {
  .debug-toggle-btn {
    right: 8px;
    top: calc(8px + env(safe-area-inset-top));
  }
  .debug-console {
    right: 8px;
    width: min(360px, calc(100vw - 16px));
    max-height: min(42vh, 300px);
  }
}


/* v2.0.0 additions */
.boot-screen{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;padding:24px;background:linear-gradient(180deg,#071120 0%,#0f172a 100%);z-index:1100;}
.boot-screen.hidden{display:none;}
.boot-screen__card{width:min(420px,92vw);padding:28px 24px;border-radius:26px;background:rgba(15,23,42,.88);box-shadow:0 20px 60px rgba(0,0,0,.35);backdrop-filter:blur(12px);text-align:center;color:#f8fafc;}
.boot-screen__logo{font-size:34px;font-weight:800;letter-spacing:.08em;margin-bottom:10px;}
.boot-screen__status{color:#cbd5e1;margin-bottom:18px;}
.boot-screen__bar{height:8px;background:rgba(255,255,255,.08);border-radius:999px;overflow:hidden;}
.boot-screen__bar span{display:block;height:100%;width:42%;background:linear-gradient(90deg,#38bdf8,#60a5fa,#22c55e);border-radius:999px;animation:bootMove 1.3s infinite ease-in-out;}
@keyframes bootMove{0%{transform:translateX(-120%)}60%{transform:translateX(170%)}100%{transform:translateX(170%)}}
.business-section{display:flex;flex-direction:column;gap:14px;}
.business-cards{display:grid;gap:12px;}
.business-card{display:flex;flex-direction:column;gap:6px;padding:14px;border-radius:18px;background:rgba(37,99,235,.08);border:1px solid rgba(96,165,250,.18);}
.business-card strong{font-size:15px;}
.business-card span{font-size:13px;color:#64748b;line-height:1.45;}
.business-actions{display:grid;gap:10px;}
.media-preview{display:none !important;}
.message-local-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px;}
.msg.local-only::after{content:"Хранится только на этом устройстве";display:block;margin-top:8px;font-size:12px;color:#64748b;}
.msg .ghost.mini{font-size:12px;padding:6px 10px;border-radius:10px;}
.dialog-loading{padding:14px 16px;border:1px dashed rgba(148,163,184,.35);border-radius:16px;background:rgba(15,23,42,.04);color:#64748b;text-align:center;}
@media (max-width:700px){.boot-screen__card{padding:24px 18px;border-radius:22px}.business-actions{grid-template-columns:1fr}.app-footer{padding-bottom:calc(12px + env(safe-area-inset-bottom));}}

.business-register-fields{display:grid;gap:10px;}
.business-note{padding:14px;border-radius:16px;background:rgba(15,23,42,.06);border:1px dashed rgba(148,163,184,.35);color:#475569;}
.business-dashboard{display:grid;gap:14px;}
.business-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;}
.business-pane{display:grid;gap:10px;padding:14px;border-radius:18px;background:rgba(15,23,42,.04);border:1px solid rgba(148,163,184,.18);}
.business-pane textarea,.business-pane input,.business-pane select{width:100%;}
.mini-kv{display:flex;justify-content:space-between;gap:12px;font-size:13px;color:#64748b;}
.mini-kv strong{color:#0f172a;font-size:14px;}


.tabs { grid-template-columns: repeat(4, 1fr); }
.avatar-wrap.clickable { cursor: pointer; }
.company-avatar {
  background: linear-gradient(135deg, #1d4ed8, #0f172a);
  color: #fff;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.company-public-card, .company-profile-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 88%, #f8fbff 12%);
  padding: 14px;
}
.company-public-head, .company-profile-head {
  display:flex; gap:12px; align-items:center; margin-bottom:12px;
}
.company-profile-grid { display:grid; gap:10px; grid-template-columns: 1fr; margin: 12px 0 6px; }
.profile-company-avatar .avatar { width:56px; height:56px; }
.guest-company-messages {
  min-height: 180px; max-height: 300px; overflow:auto; border:1px solid var(--border); border-radius:12px; padding:10px; background:#f8fbff; margin-bottom:8px;
}
.guest-bubble { padding:10px 12px; border-radius: 14px; margin-bottom:8px; background:#eef2ff; }
.guest-bubble.company { background:#e0f2fe; }
.guest-bubble.guest { background:#eff6ff; margin-left: 24px; }
.mini-kv { display:flex; justify-content:space-between; gap:10px; padding:10px 12px; border-radius:12px; background:#f8fbff; border:1px solid var(--border); }
.conv-item__title-row strong + .muted { font-size:12px; }
.search-item__body .muted { line-height:1.35; }
.auth-page .company-public-card { margin-bottom: 10px; }
@media (max-width: 700px) {
  .company-profile-card { margin: 0 10px; }
  .guest-company-messages { max-height: 220px; }
}


/* v2.3.0 company search */
.company-search-results { display:grid; gap:10px; margin-top:12px; }
.company-search-item {
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:16px;
  background:#fff;
  text-align:left;
}
.result-item__main{display:flex;align-items:center;gap:12px;}
.business-pane input[readonly], .business-pane textarea[readonly] { background: #f8fbff; }


.boot-screen{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(10,15,30,.72);backdrop-filter:blur(10px);z-index:9999}
.boot-screen.hidden{display:none}
.boot-card{width:min(360px,calc(100vw - 32px));background:linear-gradient(180deg,#0f172a,#111827);border:1px solid rgba(255,255,255,.08);color:#fff;border-radius:24px;padding:28px 24px;text-align:center;box-shadow:0 40px 120px rgba(15,23,42,.45)}
.boot-logo{font-size:34px;font-weight:800;letter-spacing:.08em;margin-bottom:14px}
.boot-spinner{width:42px;height:42px;border-radius:50%;border:3px solid rgba(255,255,255,.14);border-top-color:#60a5fa;margin:0 auto 14px;animation:nms-spin 1s linear infinite}
@keyframes nms-spin{to{transform:rotate(360deg)}}

.auth-switch{flex-wrap:wrap}
.overview-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px;margin:14px 0}
.overview-card{background:#fff;border:1px solid #e5e7eb;border-radius:18px;padding:16px;box-shadow:0 8px 30px rgba(15,23,42,.05)}
.overview-card h3{margin:0 0 10px}
.overview-card ul,.overview-card ol{margin:10px 0 0 18px;padding:0}
.overview-card li{margin:6px 0}
.inline-code{display:inline-block;padding:6px 10px;border-radius:10px;background:#eef2ff;color:#1d4ed8;font-weight:700}
.overview-shots{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px}
.overview-shot-col{display:flex;flex-direction:column;gap:10px}
.overview-shot-preview{min-height:180px;border:1px dashed #cbd5e1;border-radius:16px;background:#f8fafc;display:flex;align-items:center;justify-content:center;overflow:hidden}
.overview-shot-preview img{display:block;max-width:100%;height:auto}
#deviceKeyStatus{font-size:13px}
.auth-page h2{margin:6px 0 10px}


.public-page {
  min-height: 100vh;
  padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
}
.public-page__header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  margin-bottom:20px;
  flex-wrap:wrap;
}
.public-page__nav { display:flex; gap:10px; flex-wrap:wrap; }
.public-page__hero { margin-bottom:20px; }
.public-page__hero h1 { margin:0 0 8px; }
.public-page__hero p { margin:0; color:var(--muted, #94a3b8); }
.public-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:16px; }
.public-card { background:rgba(15,23,42,.82); border:1px solid rgba(148,163,184,.18); border-radius:18px; padding:18px; box-shadow:0 18px 45px rgba(2,6,23,.28); }
.public-card h3 { margin-top:0; }
.public-shot { width:100%; border-radius:16px; overflow:hidden; background:#0f172a; border:1px solid rgba(148,163,184,.18); min-height:180px; display:flex; align-items:center; justify-content:center; }
.public-shot img { width:100%; display:block; object-fit:cover; }
.search-page-form { display:flex; gap:10px; flex-wrap:wrap; margin:16px 0 20px; }
.search-page-form input { flex:1 1 300px; }
.company-result-card { display:flex; gap:14px; align-items:flex-start; padding:16px; border:1px solid rgba(148,163,184,.16); border-radius:16px; background:rgba(15,23,42,.72); }
.company-result-card__avatar { width:52px; height:52px; border-radius:16px; display:flex; align-items:center; justify-content:center; background:linear-gradient(135deg,#0f766e,#2563eb); font-size:26px; }
.company-result-card__body { flex:1; }
.company-result-card__meta { color:#94a3b8; font-size:14px; margin-top:4px; }
.company-result-card__actions { display:flex; gap:10px; flex-wrap:wrap; margin-top:12px; }
@media (max-width: 720px) {
  .public-page { padding-left:14px; padding-right:14px; }
}


.small-note {
  font-size: 12px;
  min-height: 18px;
}

.business-pane input,
.business-pane textarea {
  width: 100%;
}
