/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:        #f4f6f9;
  --color-surface:   #ffffff;
  --color-border:    #dde1e7;
  --color-text:      #1a1d23;
  --color-muted:     #6b7280;
  --color-primary:   #2563eb;
  --color-primary-h: #1d4ed8;
  --color-danger:    #dc2626;
  --color-success:   #16a34a;
  --color-warning:   #d97706;
  --sidebar-w:       220px;
  --radius:          6px;
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: "Fira Code", "Cascadia Code", monospace; font-size: 13px; background: #f0f0f0; padding: 1px 4px; border-radius: 3px; }
pre { background: #1e1e2e; color: #cdd6f4; padding: 12px 16px; border-radius: var(--radius); overflow-x: auto; margin: 8px 0; }
pre code { background: transparent; color: inherit; padding: 0; }
h1, h2, h3, h4 { font-weight: 600; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.mobile-nav-toggle,
.mobile-nav-overlay {
  display: none;
}

.sidebar {
  width: var(--sidebar-w);
  background: #111827;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid #1f2937;
}

.sidebar__logo { width: 48px; height: 48px; object-fit: contain; flex-shrink: 0; }
.sidebar__title { font-size: 15px; font-weight: 700; color: #f9fafb; }

.sidebar__nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #9ca3af;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #1f2937; color: #f3f4f6; text-decoration: none; }
.nav-item--active { background: #1f2937; color: #60a5fa; }
.nav-icon { font-size: 15px; }

.sidebar__footer { padding: 12px 16px; border-top: 1px solid #1f2937; }
.sidebar__user { display: flex; align-items: center; justify-content: space-between; }
.sidebar__user-name { font-size: 13px; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.sidebar__logout { font-size: 12px; color: #6b7280; }
.sidebar__logout:hover { color: #ef4444; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  max-width: 1200px;
}

.app--no-sidebar .main {
  margin-left: 0;
  max-width: none;
}

@media (max-width: 900px) {
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 1200;
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #111827;
    color: #f9fafb;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
  }

  .mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    border: none;
    z-index: 1090;
  }

  .main {
    margin-left: 0;
    max-width: none;
    padding: 64px 14px 16px;
  }

  .main.main--chat {
    padding: 0;
  }

  .main--chat .chat-sidebar__header {
    padding-top: 54px;
  }

  .chat-layout {
    position: relative;
  }

  .chat-layout .chat-sidebar,
  .chat-layout .chat-main {
    width: 100%;
    min-width: 0;
    height: 100%;
  }

  .chat-layout .chat-sidebar {
    border-right: none;
  }

  .chat-layout.chat-layout--show-list .chat-sidebar {
    display: flex;
  }

  .chat-layout.chat-layout--show-list .chat-main {
    display: none;
  }

  .chat-layout.chat-layout--show-chat .chat-sidebar {
    display: none;
  }

  .chat-layout.chat-layout--show-chat .chat-main {
    display: flex;
  }

  .chat-header__mobile-back {
    display: inline-flex;
  }

  body.mobile-chat-thread-open .mobile-nav-toggle {
    display: none;
  }

  body.mobile-chat-thread-open .app.mobile-nav-open .mobile-nav-overlay {
    display: none;
  }

  .sidebar {
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  .app.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .app.mobile-nav-open .mobile-nav-overlay {
    display: block;
  }
}

.manager-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--color-muted);
}
.manager-topbar__logout { color: #6b7280; }
.manager-topbar__logout:hover { color: #ef4444; }
.manager-mobile-menu-toggle,
.manager-mobile-menu { display: none; }

@media (max-width: 900px) {
  .app--no-sidebar .main {
    padding-top: 64px;
  }

  .manager-mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 1200;
    top: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: #111827;
    color: #f9fafb;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
  }

  .manager-mobile-menu {
    display: block;
    position: fixed;
    z-index: 1190;
    top: 58px;
    left: 10px;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 10px;
  }

  .manager-mobile-menu[hidden] {
    display: none !important;
  }

  .manager-mobile-menu__name {
    font-size: 13px;
    color: var(--color-text);
    margin: 0 0 4px;
    font-weight: 600;
    line-height: 1.2;
  }

  .manager-mobile-menu__logout {
    display: inline-flex;
    color: #dc2626;
    font-size: 13px;
    font-weight: 600;
  }

  body.body--manager .main--chat .chat-sidebar__header {
    padding-top: 10px;
  }

  body.body--manager .main--chat #js-account-select {
    width: calc(100% - 56px);
    margin-left: 56px;
  }
}

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; flex: 1; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.cards { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 28px; }
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card--account { width: 280px; }
.card--form { max-width: 560px; }
.card--danger { border-color: #fca5a5; max-width: 560px; }

.card__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fafafa;
  font-size: 13.5px;
}
.card__title { font-weight: 600; }
.card__body { padding: 14px 16px; }
.card__footer { padding: 10px 16px; border-top: 1px solid var(--color-border); display: flex; gap: 8px; }
.card__row { display: flex; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.card__label { color: var(--color-muted); min-width: 90px; }
.card__row--error .card__label { color: var(--color-danger); }

.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge--lg { font-size: 13px; padding: 4px 12px; }
.badge--new          { background: #dbeafe; color: #1d4ed8; }
.badge--auth_required { background: #fef3c7; color: #92400e; }
.badge--active       { background: #d1fae5; color: #065f46; }
.badge--error        { background: #fee2e2; color: #991b1b; }
.badge--disabled     { background: #f3f4f6; color: #6b7280; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-h); text-decoration: none; }
.btn--outline { background: #fff; border-color: var(--color-border); color: var(--color-text); }
.btn--outline:hover { background: #f9fafb; text-decoration: none; }
.btn--danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn--danger:hover { background: #b91c1c; }
.btn--warning { background: #f59e0b; color: #fff; border-color: #d97706; }
.btn--warning:hover { background: #d97706; text-decoration: none; }
.btn--warning:disabled { opacity: .55; cursor: not-allowed; }
.btn--sm { padding: 4px 10px; font-size: 12.5px; }
.btn--block { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form { padding: 20px; }
.form__group { margin-bottom: 18px; }
.form__label { display: block; margin-bottom: 5px; font-weight: 500; font-size: 13px; }
.form__input, .form__select, .form__textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff;
  color: var(--color-text);
  transition: border-color .15s;
}
.form__input:focus, .form__select:focus, .form__textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form__input--inline { width: auto; min-width: 180px; }
.form__hint { margin-top: 4px; font-size: 12px; color: var(--color-muted); }
.form__actions { display: flex; gap: 10px; padding-top: 4px; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.filter-bar .form__label { margin: 0; }
.filter-bar .form__select, .filter-bar .form__input { width: auto; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}
.table thead { background: #f9fafb; }
.table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--color-border);
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }
.table__nowrap { white-space: nowrap; }
.table__actions { display: flex; gap: 6px; }
.table__empty { text-align: center; color: var(--color-muted); padding: 24px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.alert--danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.alert--warning { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.alert--success { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.alert--sm { padding: 8px 12px; font-size: 12.5px; margin-top: 10px; margin-bottom: 0; }
.alert__list { margin-left: 18px; }

/* ── Section ──────────────────────────────────────────────────────────────── */
.section { margin-top: 28px; }
.section__title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.section-title { font-size: 14px; color: var(--color-muted); margin-bottom: 10px; }

/* ── DL ───────────────────────────────────────────────────────────────────── */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.dl dt { color: var(--color-muted); font-weight: 500; }
.dl dd { word-break: break-all; }

/* ── Info box ─────────────────────────────────────────────────────────────── */
.info-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
  max-width: 560px;
}
.info-box h3 { font-size: 14px; margin-bottom: 8px; color: #1d4ed8; }
.info-box p  { font-size: 13px; color: #1e40af; margin-bottom: 6px; }

/* ── Chat page layout ─────────────────────────────────────────────────────── */
.main--chat {
  padding: 0;
  max-width: none;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-layout {
  display: flex;
  flex: 1;
  height: 100vh;
  overflow: hidden;
}
.chat-sidebar {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  overflow: hidden;
}
.chat-sidebar__header {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  background: #fafafa;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-sidebar__header .form__select { margin: 0; }
.chat-sidebar__current-account {
  font-size: 13px;
  font-weight: 700;
  color: #14532d;
  line-height: 1.35;
}
.chat-unread-banner {
  font-size: 12px;
  line-height: 1.4;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.chat-unread-banner--header {
  font-size: 11.5px;
  padding: 5px 9px;
  max-width: min(320px, 42vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-emergency-hint {
  font-size: 11.5px;
  line-height: 1.35;
  padding: 6px 8px;
  border-radius: var(--radius);
}
.chat-emergency-hint--ok { background: #ecfdf5; color: #166534; }
.chat-emergency-hint--error { background: #fef2f2; color: #991b1b; }
.chat-app-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chat-app-status__badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.chat-app-status__badge--ok { background: #dcfce7; color: #166534; }
.chat-app-status__badge--warning { background: #fef3c7; color: #92400e; }
.chat-app-status__badge--problem { background: #fee2e2; color: #991b1b; }
.chat-app-status__badge--unknown { background: #e5e7eb; color: #374151; }
.chat-app-status__btn { padding: 3px 10px; }
.chat-app-status__meta { font-size: 11px; color: var(--color-muted); }
.chat-search { position: relative; }
.chat-search__input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 9px center;
  color: var(--color-text);
  transition: border-color .15s;
}
.chat-search__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.chat-search__input::placeholder { color: var(--color-muted); }
.chat-search__mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-list__empty { padding: 24px 16px; color: var(--color-muted); font-size: 13px; text-align: center; }
.chat-item {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background .12s;
}
.chat-item:hover { background: #f9fafb; }
.chat-item--active { background: #eff6ff; }
.chat-item__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; gap: 4px; }
.chat-item__name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.chat-item__time { font-size: 11px; color: var(--color-muted); flex-shrink: 0; }
.chat-item__preview { font-size: 12.5px; color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item__pin-btn {
  background: none; border: none; cursor: pointer; font-size: 13px; line-height: 1;
  padding: 0 1px; color: var(--color-muted); flex-shrink: 0;
  opacity: 0; transition: opacity .15s, color .15s;
}
.chat-item:hover .chat-item__pin-btn { opacity: 0.55; }
.chat-item--pinned .chat-item__pin-btn { opacity: 1; color: #f59e0b; }
.chat-item__pin-btn:hover { opacity: 1 !important; color: #f59e0b; }
.chat-item--pinned { background: #fffbeb; }
.chat-item--pinned:hover { background: #fef3c7; }
.chat-item--pinned.chat-item--active { background: #fef3c7; }
.chat-item--unread {
  background: #fff7ed;
  border-left: 3px solid #f97316;
}
.chat-item--unread:hover { background: #ffedd5; }
.chat-item--unread.chat-item--active { background: #ffedd5; }
.chat-item--unread .chat-item__name { color: #9a3412; }
.chat-item--unread .chat-item__preview { color: #c2410c; font-weight: 600; }
.chat-item__unread-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f97316;
  margin-right: 2px;
}
.chat-list__divider { padding: 4px 14px; font-size: 11px; color: var(--color-muted); text-transform: uppercase; letter-spacing: .5px; background: #f9fafb; border-bottom: 1px solid #f0f0f0; }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--color-bg); }
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  flex-shrink: 0;
  display: flex;
}
.chat-header__top {
  display: flex;
  align-items: center;
  gap: 10px 12px;
  flex-wrap: wrap;
}
.chat-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.chat-header__hint {
  margin-top: 2px;
}
.chat-header__mobile-back { display: none; }
.chat-header__name { font-weight: 700; font-size: 15px; flex-shrink: 0; }
.chat-header__peer { font-size: 12px; color: var(--color-muted); flex-shrink: 0; }
.chat-header__sub { font-size: 12px; color: var(--color-muted); }
.chat-inbox-toast[hidden] {
  display: none !important;
}
.chat-inbox-toast:not([hidden]) {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0 16px 8px;
  border-radius: var(--radius);
  background: #eff6ff;
  border: 1px solid #93c5fd;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
  overflow: hidden;
  flex-shrink: 0;
  animation: chat-inbox-toast-in .2s ease-out;
}
@keyframes chat-inbox-toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-inbox-toast__body {
  flex: 1;
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
  color: #1e3a8a;
  background: transparent;
  border: none;
  cursor: pointer;
}
.chat-inbox-toast__body:hover { background: #dbeafe; }
.chat-inbox-toast__close {
  flex-shrink: 0;
  width: 36px;
  border: none;
  border-left: 1px solid #93c5fd;
  background: transparent;
  color: #1d4ed8;
  cursor: pointer;
  font-size: 14px;
}
.chat-inbox-toast__close:hover { background: #dbeafe; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-messages__empty,
.chat-messages__loading { margin: auto; color: var(--color-muted); font-size: 13px; }
.chat-msg {
  max-width: 70%;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}
.chat-msg--in  { align-self: flex-start; background: #fff; border: 1px solid var(--color-border); border-bottom-left-radius: 3px; }
.chat-msg--out { align-self: flex-end; background: #dbeafe; border-bottom-right-radius: 3px; }
.chat-msg__body { margin-bottom: 4px; }
.chat-msg__reply {
  width: 100%;
  text-align: left;
  border: none;
  cursor: pointer;
  border-left: 3px solid #93c5fd;
  background: rgba(147, 197, 253, 0.18);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 6px;
  display: block;
}
.chat-msg__reply-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: #1d4ed8;
  margin-bottom: 2px;
}
.chat-msg__reply-text {
  display: block;
  font-size: 12px;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-msg--highlight {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
}
.chat-msg__meta { font-size: 11px; color: var(--color-muted); display: flex; gap: 6px; align-items: center; }
.chat-msg__reply-action {
  border: none;
  background: transparent;
  color: #2563eb;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.chat-msg__reply-action:hover { text-decoration: underline; }
.chat-msg__badge { font-size: 10px; background: #bfdbfe; color: #1d4ed8; padding: 1px 5px; border-radius: 8px; }
.chat-footer { flex-shrink: 0; border-top: 1px solid var(--color-border); background: var(--color-surface); }
.chat-reply-box {
  margin: 10px 16px 0;
  padding: 8px 10px;
  border-left: 3px solid #60a5fa;
  background: #eff6ff;
  border-radius: 6px;
  position: relative;
}
.chat-reply-box__title { font-size: 11px; color: #1d4ed8; font-weight: 700; margin-bottom: 2px; }
.chat-reply-box__text {
  font-size: 12.5px;
  color: #334155;
  padding-right: 28px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-reply-box__cancel {
  position: absolute;
  right: 8px;
  top: 8px;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.chat-reply-box__cancel:hover { color: #0f172a; }
.chat-footer__row { display: flex; gap: 10px; align-items: flex-end; padding: 12px 16px; }
.chat-footer__input {
  flex: 1; resize: none; min-height: 42px; max-height: 160px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 8px 12px; font-size: 14px; font-family: inherit; line-height: 1.4;
}
.chat-footer__input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.chat-footer__btn { flex-shrink: 0; height: 42px; padding: 0 20px; }
.chat-footer__attach { flex-shrink: 0; height: 42px; min-width: 44px; padding: 0 10px; }
.chat-send-icon { display: none; }

@media (max-width: 900px) {
  .chat-footer {
    background: #fff;
    border-top-color: #dbe1ea;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .chat-footer__row--files {
    align-items: center;
    gap: 8px;
    padding: 10px 10px 10px;
  }

  .chat-footer__attach {
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
  }

  .chat-footer__input {
    min-height: 40px;
    max-height: 132px;
    border-radius: 20px;
    padding: 9px 12px;
    font-size: 16px;
    line-height: 1.3;
  }

  .chat-footer__btn {
    height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
  }

  .chat-send-label {
    display: none;
  }

  .chat-send-icon {
    display: inline;
    font-size: 17px;
    line-height: 1;
  }

  .chat-reply-box {
    margin: 8px 10px 0;
  }
}

.emoji-picker[hidden] { display: none; }
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  width: 300px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px;
  z-index: 100;
}
.emoji-picker__section-title {
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-muted);
  margin: 4px 2px 2px;
}
.emoji-picker__btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background .1s;
  line-height: 1;
}
.emoji-picker__btn:hover { background: var(--color-bg); }
.chat-msg__text { margin-top: 4px; }
.msg-status { font-size: 11px; margin-left: 3px; font-weight: 600; flex-shrink: 0; }
.msg-status--sent { color: var(--color-muted); }
.msg-status--read { color: #2563eb; }
.chat-msg__img {
  max-width: min(280px, 90vw);
  max-height: 360px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 8px;
  object-fit: contain;
}
.chat-msg__file { font-weight: 500; }

/* ── Chat window (legacy) ─────────────────────────────────────────────────── */
.chat-window {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.chat-window__empty { margin: auto; color: var(--color-muted); font-size: 13px; }

.message {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
}
.message--in {
  align-self: flex-start;
  background: #f3f4f6;
  border-bottom-left-radius: 3px;
}
.message--out {
  align-self: flex-end;
  background: #dbeafe;
  border-bottom-right-radius: 3px;
}
.message__meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.message__sender { font-weight: 600; font-size: 12px; color: var(--color-primary); }
.message__time   { font-size: 11px; color: var(--color-muted); }
.message__badge  { font-size: 10px; background: #bfdbfe; color: #1d4ed8; padding: 1px 5px; border-radius: 8px; }
.message__body   { word-break: break-word; }

/* ── Reply form ───────────────────────────────────────────────────────────── */
.reply-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.reply-form__input { flex: 1; resize: vertical; min-height: 60px; }
.reply-form__btn { flex-shrink: 0; height: 60px; padding: 0 20px; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.body--login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}
.login-wrap { width: 100%; max-width: 400px; padding: 20px; }
.login-card {
  background: #fff;
  border-radius: 10px;
  padding: 36px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.login-card__logo  { font-size: 40px; text-align: center; margin-bottom: 8px; }
.login-card__title { text-align: center; font-size: 18px; margin-bottom: 24px; color: var(--color-text); }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px;
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  width: 100%;
  color: var(--color-muted);
}

.pwa-install-btn {
  position: fixed;
  right: 12px;
  bottom: 14px;
  z-index: 1250;
  border: none;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.pwa-install-tip {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 1250;
  background: #111827;
  color: #f9fafb;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 12px;
  box-shadow: var(--shadow);
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
