@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --bg-soft: #f5f5f3;
  --bg-soft-2: #f0f0ee;
  --border: #e8e8e6;
  --border-soft: rgba(0, 0, 0, 0.04);
  --text: #1a1a1a;
  --text-mid: #666666;
  --text-dim: #999999;
  --text-faint: #cccccc;
  --accent: #f97316;
  --accent-bg: rgba(249, 115, 22, 0.06);
  --accent-bg-soft: rgba(249, 115, 22, 0.04);
  --accent-border: rgba(249, 115, 22, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --danger: #ef4444;
  --tag-bg: #f5f3ff;
  --tag-text: #7c3aed;
  --tg: #29b6f6;
  --wa: #25d366;

  /* Message bubble palette — distinct tints per sender role so the
     operator can tell guest / system / AI / manager apart at a glance
     without reading the label. Colors stay muted to not fight the
     warm-neutral base theme; each also gets a 3px accent stripe on
     the inside edge for extra redundancy. */
  --bubble-guest-bg: #ffffff;
  --bubble-guest-border: #e5e7eb;
  --bubble-guest-stripe: #9ca3af;
  --bubble-guest-text: #111827;

  --bubble-system-bg: #fef7e6;
  --bubble-system-border: #fcd9a0;
  --bubble-system-stripe: #f59e0b;
  --bubble-system-text: #78350f;

  --bubble-ai-bg: #eff6ff;
  --bubble-ai-border: #bfdbfe;
  --bubble-ai-stripe: #3b82f6;
  --bubble-ai-text: #1e3a8a;

  --bubble-human-bg: #1a1a1a;
  --bubble-human-border: #1a1a1a;
  --bubble-human-stripe: #f97316;
  --bubble-human-text: #ffffff;

  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  cursor: pointer;
  font-family: inherit;
}

input,
textarea {
  font: inherit;
  font-family: inherit;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Login ────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 28px 24px;
  width: min(360px, 100%);
}

.login-card .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.login-card .brand-square {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.login-card h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
}

.login-card .sub {
  color: var(--text-dim);
  font-size: 11px;
  margin: -2px 0 22px 38px;
}

.login-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.login-tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.login-tab:not(:last-child) {
  border-right: 1px solid var(--border);
}

.login-tab.active {
  background: var(--bg-card);
  color: var(--text);
}

.login-tab:hover:not(.active) {
  background: var(--bg);
}

.venue-login-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.venue-login-select:focus {
  border-color: var(--text);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  outline: none;
  font-size: 13px;
  transition: border-color 0.12s;
}

.field input:focus {
  border-color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-mid);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.btn:hover:not(:disabled) {
  background: var(--bg-soft);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: #000;
}

.btn-block {
  width: 100%;
  padding: 11px;
  font-size: 13px;
}

.err {
  color: var(--danger);
  font-size: 12px;
  min-height: 1.2em;
  margin: 4px 0 8px;
}

/* ─── App shell ────────────────────────────────────────────── */

.shell {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* ─── Left panel ───────────────────────────────────────────── */

.left {
  width: 320px;
  min-width: 320px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.left .header {
  padding: 20px 20px 16px;
}

.left .header .row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.square {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-transform: uppercase;
}

.left .header .venue {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.left .header .sub {
  font-size: 11px;
  color: var(--text-dim);
  margin: -2px 0 0 38px;
}

.left .header .logout {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
}

.left .header .logout:hover {
  color: var(--text);
}

.stats {
  display: flex;
  margin: 0 16px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.stat {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
}

.stat:last-child {
  border-right: none;
}

.stat.warn-active {
  background: var(--accent-bg-soft);
}

.stat .v {
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.stat.waiting .v {
  color: var(--accent);
}
.stat.active .v {
  color: var(--success);
}
.stat.bot .v {
  color: #9ca3af;
}

.stat .l {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-wrap {
  padding: 0 16px;
  margin-bottom: 8px;
}

.search-wrap input {
  width: 100%;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
  outline: none;
  transition: border-color 0.12s;
}

.search-wrap input:focus {
  border-color: var(--text);
}

.filters {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  margin-bottom: 8px;
}

.chip {
  padding: 4px 10px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s;
}

.chip:hover {
  color: var(--text-mid);
}

.chip.active {
  background: var(--text);
  color: #fff;
}

.list {
  flex: 1;
  overflow-y: auto;
}

.conv-row {
  padding: 12px 20px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.12s;
  animation: fadeUp 0.25s ease both;
}

.conv-row:hover {
  background: var(--bg-soft);
}

.conv-row.selected {
  border-left-color: var(--text);
  background: var(--bg-soft);
}

.conv-row .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.conv-row .head .l {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg-soft-2);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.avatar.waiting {
  background: var(--accent);
  color: #fff;
}

.conv-row .name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-row .meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.conv-row .right {
  /* Override the bare `.right` selector below (line ~1064) which sets
     `width: 280px; min-width: 280px;` for the right info panel. That
     selector matches ANY .right by class, so without these overrides
     the conv row's timestamp cell takes 280px and squashes the name
     to width: 0. */
  width: auto;
  min-width: 0;
  text-align: right;
  flex-shrink: 0;
  margin-left: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: transparent;
  border-left: 0;
  overflow: visible;
}

.conv-row .time {
  font-size: 10px;
  color: var(--text-dim);
  font-family: "IBM Plex Mono", monospace;
}

.unread-dot {
  margin-top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.conv-row .preview {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
  margin-top: 6px;
  padding-left: 42px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-row .tags {
  display: flex;
  gap: 4px;
  padding-left: 42px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.tag {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-weight: 500;
}

.empty-list {
  color: var(--text-faint);
  padding: 2rem 1rem;
  text-align: center;
  font-size: 12px;
}

.managers {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.managers .label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.managers .strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.manager-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-mid);
}

.manager-pill .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
}

/* ─── Status / channel badges ───────────────────────────── */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.status-badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.status-badge.waiting {
  color: var(--accent);
  background: rgba(249, 115, 22, 0.1);
}

.status-badge.waiting .dot {
  background: var(--accent);
  animation: pulse 1.5s infinite;
}

.status-badge.active {
  color: var(--success);
  background: var(--success-bg);
}

.status-badge.active .dot {
  background: var(--success);
}

.status-badge.bot {
  color: #6b7280;
  background: rgba(107, 114, 128, 0.1);
}

.status-badge.bot .dot {
  background: #6b7280;
}

.status-badge.snoozed,
.status-badge.closed {
  color: #475569;
  background: rgba(71, 85, 105, 0.08);
}

.status-badge.closed .dot {
  background: #475569;
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
}

.channel-badge.tg {
  color: var(--tg);
}

.channel-badge.wa {
  color: var(--wa);
}

.channel-badge.sms {
  color: #94a3b8;
}

/* ─── Booking tab ──────────────────────────────────────────────
 *
 * The "Бронь" tab in the right info panel. Renders a current/upcoming
 * booking card on top, optional history list below, and a "Create"
 * button at the very top. Driven by /v1/inbox/conversations/{id}/bookings
 * which proxies to booking-backend.
 */

.booking-tab {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.booking-tab__header {
  display: flex;
}

.booking-tab__create {
  flex: 1;
}

.booking-empty {
  padding: 24px 16px;
  text-align: center;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.booking-empty--error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.04);
}

.booking-empty__icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.booking-empty__hint {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.booking-empty__phone {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
}

.booking-empty__error {
  margin-top: 8px;
  font-size: 11px;
  color: var(--danger);
  font-family: "IBM Plex Mono", monospace;
}

.booking-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  position: relative;
}

.booking-card__status {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-soft);
  margin-bottom: 10px;
}

.booking-status--confirmed,
.booking-card__status.booking-status--confirmed {
  color: var(--success);
  background: var(--success-bg);
}

.booking-status--pending,
.booking-card__status.booking-status--pending {
  color: var(--accent);
  background: var(--accent-bg);
}

.booking-status--pending-deposit,
.booking-card__status.booking-status--pending-deposit {
  color: var(--accent);
  background: var(--accent-bg);
}

.booking-status--cancelled,
.booking-card__status.booking-status--cancelled {
  color: var(--text-faint);
  background: var(--bg-soft);
  text-decoration: line-through;
}

.booking-status--arrived,
.booking-card__status.booking-status--arrived {
  color: var(--success);
  background: var(--success-bg);
}

.booking-status--no-show,
.booking-card__status.booking-status--no-show {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.booking-status--finished,
.booking-card__status.booking-status--finished {
  color: var(--text-dim);
  background: var(--bg-soft);
}

.booking-card__quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.btn-quick {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  flex: 1;
  min-width: 70px;
}

.btn-quick:hover {
  background: var(--bg-soft-2);
}

.btn-quick--success {
  border-color: var(--success);
  color: var(--success);
}

.btn-quick--success:hover {
  background: var(--success);
  color: #fff;
}

.btn-quick--warn {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-quick--warn:hover {
  background: var(--accent);
  color: #fff;
}

.booking-card__date {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 2px;
  text-transform: capitalize;
}

.booking-card__time {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  margin-bottom: 4px;
}

.booking-card__duration {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  font-family: inherit;
}

.booking-card__guests {
  font-size: 13px;
  color: var(--text-mid);
  margin-bottom: 12px;
}

.booking-card__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}

.booking-card__row .k {
  color: var(--text-faint);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.4px;
}

.booking-card__row .v {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.booking-card__row .v a {
  color: var(--accent);
  text-decoration: none;
}

.booking-card__row .v a:hover {
  text-decoration: underline;
}

.booking-card__comment {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.booking-card__comment .k {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.booking-card__comment .comment-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}

.booking-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.booking-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-soft);
  color: var(--text-dim);
  font-family: "IBM Plex Mono", monospace;
}

.booking-card__actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.booking-card__actions .btn {
  flex: 1;
  font-size: 11px;
}

.btn-small {
  padding: 6px 10px;
  font-size: 11px;
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

.booking-card__id {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 10px;
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
}

.booking-upcoming {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.booking-upcoming__label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.upcoming-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  position: relative;
}

.upcoming-row__main {
  flex: 1;
  min-width: 0;
}

.upcoming-row__date {
  color: var(--text);
  font-weight: 600;
  text-transform: capitalize;
}

.upcoming-row__meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.upcoming-row__actions {
  display: flex;
  gap: 4px;
}

.upcoming-row__btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-mid);
}

.upcoming-row__btn:hover {
  background: var(--bg-soft-2);
  color: var(--text);
}

.upcoming-row__btn--danger {
  color: var(--danger);
  border-color: var(--border);
}

.upcoming-row__btn--danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.upcoming-row__id {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 9px;
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
}

.booking-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.booking-history__label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.history-row__date {
  color: var(--text);
  font-weight: 500;
}

.history-row__meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.history-row__id {
  font-size: 10px;
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
}

.booking-history__more {
  background: none;
  border: 0;
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}

.booking-history__more:hover {
  color: var(--text);
}

/* ─── Audit log (Phase B) ──────────────────────────────────── */

.audit-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.audit-log__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 0;
  padding: 4px 0;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  cursor: pointer;
  font-family: inherit;
}

.audit-log__header:hover {
  color: var(--text-mid);
}

.audit-log__chevron {
  font-size: 11px;
  color: var(--text-faint);
}

.audit-row {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.audit-row__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.audit-row__label {
  color: var(--text);
  font-weight: 500;
}

.audit-row__id {
  font-size: 10px;
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
}

.audit-row__meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
}

.audit-row__warning {
  color: var(--accent);
  font-weight: 500;
}

.audit-log__more {
  background: none;
  border: 0;
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  align-self: flex-start;
}

.audit-log__more:hover {
  color: var(--text);
}

/* ─── Booking modals (Slice 2) ─────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: fadeIn 0.15s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.18s ease both;
}

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

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.modal__close {
  background: none;
  border: 0;
  font-size: 18px;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.modal__close:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.modal__body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal__error {
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid var(--danger);
  border-radius: 6px;
  color: var(--danger);
  font-size: 12px;
}

.modal__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.modal__actions .btn {
  min-width: 100px;
}

/* Booking edit form fields */

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
}

.form-row input[type="text"],
.form-row input[type="tel"],
.form-row input[type="date"],
.form-row input[type="time"],
.form-row input[type="number"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  box-sizing: border-box;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-row textarea {
  resize: vertical;
  min-height: 70px;
  font-family: inherit;
}

.form-row--inline {
  display: flex;
  flex-direction: row;
  gap: 12px;
}

.form-row--inline .form-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row--inline label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-faint);
}

/* Cancel confirmation dialog */

.cancel-modal__summary {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.cancel-modal__id {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 10px;
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
}

.cancel-modal__warning {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  background: rgba(239, 68, 68, 0.04);
  border-left: 3px solid var(--danger);
  padding: 10px 12px;
  border-radius: 4px;
}

/* ─── Center chat ─────────────────────────────────────────── */

.chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--text-faint);
  font-size: 13px;
}

.chat-header {
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-header .title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header .title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.chat-header .sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
}

.chat-header .sub .sep {
  color: var(--border);
}

.chat-header .sub .assignee {
  color: var(--success);
  font-weight: 500;
}

.chat-header .actions {
  display: flex;
  gap: 6px;
}

.chat-header .actions .btn {
  padding: 6px 14px;
  font-size: 12px;
}

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg);
}

.day-divider {
  text-align: center;
  margin-bottom: 20px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
}

/*
 * Conversation divider — separates one logical "phase" of an ongoing
 * conversation from the next. We collapsed all bookings for a guest
 * into one thread; the divider tells the operator where one booking's
 * notification chain ended and the next began. Driven by the
 * messages.metadata.booking_id transition in the message stream.
 */
.conversation-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 22px 0 14px;
  gap: 12px;
  animation: fadeUp 0.2s ease both;
}

.conversation-divider::before,
.conversation-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.conversation-divider span {
  font-size: 11px;
  color: var(--text-mid);
  font-weight: 500;
  font-family: "IBM Plex Mono", monospace;
  padding: 4px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

.system-line {
  text-align: center;
  margin: 14px 0;
  animation: fadeUp 0.2s ease both;
}

.system-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-mid);
  font-weight: 500;
}

.system-pill.escalation {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

.system-pill.closed {
  background: rgba(34, 197, 94, 0.06);
  border-color: rgba(34, 197, 94, 0.18);
  color: var(--success);
}

.system-pill .t {
  color: var(--text-faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  margin-left: 6px;
}

.bubble-row {
  display: flex;
  width: 100%;
  margin-bottom: 6px;
  animation: fadeUp 0.2s ease both;
}

.bubble-row.left {
  justify-content: flex-start;
}

.bubble-row.right {
  justify-content: flex-end;
}

.bubble {
  /* Fill the row up to 720px so we don't waste horizontal space when
     the chat panel is narrow. `flex-shrink: 0` is REQUIRED — without
     it the parent flex `.bubble-row` collapses the bubble to its
     content width, which is why short messages ("Ok") looked tiny
     and long booking templates wrapped weirdly even after the width
     was set. With flex-shrink off the bubble holds its computed
     width regardless of content. */
  flex: 0 0 auto;
  width: min(720px, calc(100% - 16px));
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-sizing: border-box;
}

/* Guest (inbound from the customer) — neutral white with a grey stripe
   on the left edge. The stripe is the "unread / not-from-us" signal. */
.bubble.guest {
  background: var(--bubble-guest-bg);
  border: 1px solid var(--bubble-guest-border);
  border-left: 3px solid var(--bubble-guest-stripe);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  color: var(--bubble-guest-text);
  border-bottom-left-radius: 2px;
}

/* AI agent reply — soft blue tint with a blue stripe. Distinct from
   manager replies so the operator can see at a glance whether the
   last message was from the bot or a human. */
.bubble.bot,
.bubble.agent_ai {
  background: var(--bubble-ai-bg);
  border: 1px solid var(--bubble-ai-border);
  border-right: 3px solid var(--bubble-ai-stripe);
  color: var(--bubble-ai-text);
  border-bottom-right-radius: 2px;
}

/* System messages = booking notifications (template-driven) OR
   state-transition markers (taken_over / escalation / closed).
   Warm amber tint so they read as "automated / template" rather than
   AI or human. */
.bubble.system {
  background: var(--bubble-system-bg);
  border: 1px solid var(--bubble-system-border);
  border-right: 3px solid var(--bubble-system-stripe);
  color: var(--bubble-system-text);
  border-bottom-right-radius: 2px;
}

/* Manager (human operator) reply — dark solid with an orange accent
   stripe. Highest visual weight because it's the signal "a human was
   here". */
.bubble.agent_human {
  background: var(--bubble-human-bg);
  border: 1px solid var(--bubble-human-border);
  border-right: 3px solid var(--bubble-human-stripe);
  color: var(--bubble-human-text);
  border-bottom-right-radius: 2px;
}

/* Channel badge in the bubble header (TG / SMS / VK MAX) so operators
   can tell at a glance which transport a message went through. Scoped
   to .bubble so it doesn't collide with the .channel-badge variant
   used in the conversation list rows above. */
.bubble .sender-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.bubble .channel-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-mid);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
}

.bubble.agent_ai .channel-badge {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #1e40af;
}

.bubble.system .channel-badge {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #92400e;
}

.bubble.agent_human .channel-badge {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.85);
}

.bubble.failed {
  border-color: var(--danger);
  opacity: 0.85;
}

.bubble .sender {
  font-size: 10px;
  font-weight: 600;
}

.bubble.guest .sender {
  color: #6b7280;
}

.bubble.bot .sender,
.bubble.agent_ai .sender {
  color: #1e40af;
}

.bubble.system .sender {
  color: #92400e;
}

.bubble.agent_human .sender {
  color: rgba(255, 255, 255, 0.55);
}

.voice-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  letter-spacing: 0.2px;
}

.bubble .t {
  font-size: 10px;
  margin-top: 3px;
  font-family: "IBM Plex Mono", monospace;
  color: var(--text-faint);
}

.bubble.guest .t {
  text-align: left;
}

.bubble.bot .t,
.bubble.agent_ai .t,
.bubble.system .t,
.bubble.agent_human .t {
  text-align: right;
}

.bubble.agent_ai .t {
  color: #6b7ea8;
}

.bubble.system .t {
  color: #b45309;
}

.bubble.agent_human .t {
  color: rgba(255, 255, 255, 0.4);
}

.bubble .err {
  font-size: 10px;
  color: var(--danger);
  margin-top: 3px;
}

/* ─── Composer ───────────────────────────────────────────── */

.composer-disabled {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 12px;
}

.composer-disabled .btn {
  margin-left: auto;
}

.composer-disabled.escalated {
  background: var(--accent-bg);
  border-top-color: var(--accent-border);
  color: var(--accent);
  font-weight: 500;
}

.composer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

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

.quick-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.quick-btn.active {
  background: var(--bg-soft);
}

.composer-input {
  flex: 1;
  display: flex;
  align-items: flex-end;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 4px 0 12px;
  background: var(--bg-card);
  transition: border-color 0.12s;
}

.composer-input:focus-within {
  border-color: var(--text);
}

.composer-input textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 13px;
  padding: 8px 0;
  line-height: 1.5;
  max-height: 120px;
}

.send-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: var(--bg-soft-2);
  color: var(--text-faint);
  display: grid;
  place-items: center;
  margin: 3px 0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.send-btn.ready {
  background: var(--text);
  color: #fff;
}

.composer .hint {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 6px;
}

.quick-replies {
  padding: 10px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  animation: fadeUp 0.15s ease;
}

.quick-replies .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.quick-reply {
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-mid);
  font-size: 11px;
}

.quick-reply:hover {
  background: var(--bg-soft);
}

/* ─── Right panel ────────────────────────────────────────── */

.right {
  width: 280px;
  min-width: 280px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right .tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.right .tab {
  flex: 1;
  padding: 12px 0;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
}

.right .tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.right .body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

.right .avatar-block {
  text-align: center;
  margin-bottom: 20px;
}

.right .avatar-block .big {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin: 0 auto 8px;
  background: var(--bg-soft-2);
  color: var(--text-dim);
  font-size: 16px;
  font-weight: 600;
  display: grid;
  place-items: center;
  text-transform: uppercase;
}

.right .avatar-block .name {
  font-size: 14px;
  font-weight: 600;
}

.right .avatar-block .phone {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.right .avatar-block .tags {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.kv-card {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border-soft);
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-row .k {
  color: var(--text-dim);
}

.kv-row .v {
  font-weight: 500;
  color: var(--text);
}

.ai-summary {
  padding: 12px;
  border-radius: 8px;
  background: var(--accent-bg-soft);
  border: 1px solid var(--accent-border);
  margin-bottom: 16px;
}

.ai-summary .label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-summary .body {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-mid);
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.action-btn {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 3px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-mid);
  font-size: 12px;
  text-align: left;
  transition: background 0.12s;
}

.action-btn:hover {
  background: var(--bg-soft);
}

/* ─── Phase 6b additions ───────────────────────────────────── */

/* Sound toggle button in the left panel header */
.left .header .venue-select {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
  text-overflow: ellipsis;
}

.left .header .venue-select:focus {
  border-color: var(--accent);
}

.left .header .help-btn {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.left .header .help-btn:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.left .header .sound-btn {
  margin-left: 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}

.left .header .sound-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

/* Logout button: no longer auto-margin (sound-btn takes that spot) */
.left .header .logout {
  margin-left: 0;
}

/* Editable tag chips in the right panel */
.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}

.tag-editor .tag.editable {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
}

.tag-editor .tag .rm {
  border: none;
  background: transparent;
  color: var(--tag-text);
  opacity: 0.6;
  font-size: 13px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 3px;
  cursor: pointer;
}

.tag-editor .tag .rm:hover {
  opacity: 1;
  background: rgba(124, 58, 237, 0.12);
}

.tag-add {
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
}

.tag-add:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.tag-input {
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid var(--text);
  background: var(--bg-card);
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  width: 120px;
}

/* Notes editor (special_requests) in the right panel */
.notes-editor {
  margin-bottom: 16px;
}

.notes-editor textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  max-height: 160px;
  outline: none;
  transition: border-color 0.12s;
  font-family: inherit;
}

.notes-editor textarea:focus {
  border-color: var(--text);
}

.notes-editor .notes-status {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Copy-to-clipboard button next to the phone */
.right .avatar-block .phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}

.copy-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

/* Richer quick-reply list — templates come from the server with
   {title, content}, so we render them stacked instead of horizontal
   pills and add an inline search input. */
.quick-replies {
  max-height: 260px;
  overflow-y: auto;
}

.quick-replies .wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quick-search {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  font-size: 12px;
  outline: none;
  margin-bottom: 4px;
  width: 100%;
}

.quick-search:focus {
  border-color: var(--text);
}

.quick-reply {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-align: left;
  width: 100%;
}

.quick-reply .q-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.quick-reply .q-body {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.quick-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
}

/* ─── Mobile header (desktop-hidden by default) ───────────────
 *
 * The mobile stack-navigator header. Always rendered by <InboxView>
 * but hidden outside the ≤900px media query. On mobile it sits
 * sticky at the top with a back button + title + optional info
 * button.
 */

.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: max(8px, env(safe-area-inset-top)) 12px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 12px;
  min-height: 52px;
  flex: 0 0 auto;
}

.mobile-header .mh-venue {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.mobile-header .mh-title-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mobile-header .mh-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.mobile-header .mh-sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 2px;
}

.mobile-header .mh-back,
.mobile-header .mh-info {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mobile-header .mh-back:active,
.mobile-header .mh-info:active {
  background: var(--bg);
}

.mobile-header .mh-back {
  margin-left: -4px;
  font-size: 34px;
  font-weight: 300;
}

.mobile-header .mh-info {
  font-size: 22px;
  opacity: 0.7;
}

/* ─── Mobile layout (≤900px) ──────────────────────────────────
 *
 * Stack navigator: the three panes become three full-screen views
 * controlled by [data-mobile-view] on .shell. Only the active pane
 * is displayed; the others stay mounted with display:none so
 * React state + scroll positions + SSE subscriptions all persist
 * across view switches.
 *
 * Desktop (>900px) ignores every rule in this block — the 3-pane
 * flexbox layout above is unchanged.
 */

@media (max-width: 900px) {
  .shell {
    flex-direction: column;
    height: 100dvh; /* dynamic viewport height — shrinks with iOS keyboard */
  }

  .mobile-header {
    display: flex;
  }

  /* All three panes become full-width, borderless, flex-1 */
  .left,
  .chat,
  .right {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    border-left: none;
    border-right: none;
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Stack navigation — show only the active pane */
  .shell[data-mobile-view="list"] .chat,
  .shell[data-mobile-view="list"] .right {
    display: none;
  }
  .shell[data-mobile-view="chat"] .left,
  .shell[data-mobile-view="chat"] .right {
    display: none;
  }
  .shell[data-mobile-view="info"] .left,
  .shell[data-mobile-view="info"] .chat {
    display: none;
  }

  /* ─── Left panel (list view) ─────────────────────────── */

  /* The left panel's own venue header duplicates the mobile
   * header — hide it on mobile so the venue doesn't show twice.
   * Keep the sound toggle + logout buttons accessible by moving
   * them into a compact row above the stats. */
  .left .header {
    padding: 4px 16px 8px;
  }
  .left .header .row .square,
  .left .header .row .venue,
  .left .header .sub {
    display: none;
  }
  .left .header .row {
    justify-content: flex-end;
    gap: 6px;
  }

  .left .stats {
    padding: 8px 16px;
    gap: 8px;
  }
  .left .stats .stat {
    padding: 10px 8px;
  }
  .left .stats .stat .v {
    font-size: 22px;
  }
  .left .stats .stat .l {
    font-size: 10px;
  }

  .left .search-wrap {
    padding: 8px 16px;
  }
  .left .search-wrap input {
    font-size: 16px; /* prevent iOS zoom-on-focus */
    padding: 12px 14px;
  }

  .left .filters {
    padding: 0 16px 12px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .left .filters .chip {
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
  }

  .left .list {
    -webkit-overflow-scrolling: touch;
  }
  .left .list .conv-row {
    padding: 14px 16px;
    min-height: 72px;
  }

  /* Online managers strip is noise on mobile list view */
  .left .managers {
    display: none;
  }

  /* ─── Chat pane ──────────────────────────────────────── */

  .chat-header {
    padding: 10px 14px;
    gap: 10px;
  }
  /* Hide the chat header's own title/subtitle on mobile — the
   * mobile header already shows the guest name + status. Keep
   * the actions group for take/return/close buttons.
   *
   * The inner wrapper is a class-less <div>, so we target the
   * first child of .chat-header to hide it entirely — that
   * removes both .title-row and .sub in one selector. */
  .chat-header > div:first-child {
    display: none;
  }
  .chat-header {
    justify-content: flex-end;
  }
  .chat-header .actions {
    margin-left: 0;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
  }
  .chat-header .actions .btn {
    flex: 0 1 auto;
    min-height: 38px;
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
    touch-action: manipulation;
  }

  .feed {
    padding: 12px 14px 16px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .feed .day-divider {
    font-size: 11px;
    margin: 8px 0 12px;
  }

  /*
   * Mobile bubble override.
   *
   * Two separate fixes here for the "bubbles render into the DOM
   * but are invisible on real mobile viewports" bug:
   *
   * 1. `width: auto`. The desktop .bubble rule uses
   *    `width: min(720px, calc(100% - 16px))` combined with
   *    `flex: 0 0 auto`. On narrow mobile viewports inside a
   *    flex column chat pane sized via `height: 100dvh`, iOS
   *    Safari can resolve the calc-with-% to a zero main-axis
   *    size during layout, which collapses the bubble row to
   *    0 height and makes the content invisible. Forcing
   *    `width: auto` + `flex: 0 1 auto` makes the bubble size
   *    naturally from its content with max-width as the cap.
   *
   * 2. Animation override. `.bubble-row` has
   *    `animation: fadeUp 0.2s ease both` which starts at
   *    `opacity: 0; transform: translateY(6px)`. When the
   *    chat pane flips from `display: none` (list view) to
   *    `display: flex` (chat view) via the mobile stack
   *    navigator, iOS Safari occasionally fails to run the
   *    animation, leaving the `from` state stuck permanently
   *    because `animation-fill-mode: both` pins the pre-
   *    animation state when the animation hasn't advanced.
   *    The explicit `animation: none` + explicit `opacity: 1`
   *    + `transform: none` defeats the stuck-state case.
   *    The same animation on `.system-line` and
   *    `.conversation-divider` works fine because they exist
   *    outside the display-none→flex transition path.
   */
  .bubble {
    width: auto;
    max-width: 85%;
    flex: 0 1 auto;
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.45;
  }
  .bubble-row {
    margin-bottom: 8px;
    animation: none;
    opacity: 1;
    transform: none;
  }

  /* System pills in the feed stay narrow and centered */
  .system-pill {
    max-width: 85%;
    font-size: 11px;
  }

  /* ─── Composer ───────────────────────────────────────── */

  .composer {
    padding: 10px 12px
      calc(10px + max(0px, env(safe-area-inset-bottom)));
    flex: 0 0 auto;
  }
  .composer .row {
    gap: 8px;
  }
  .composer-input {
    min-height: 44px;
  }
  .composer-input textarea {
    font-size: 16px; /* prevent iOS zoom-on-focus */
    line-height: 1.4;
    min-height: 44px;
    max-height: 40vh;
  }
  .composer .hint {
    display: none;
  }
  .composer .send-btn {
    min-width: 54px;
    min-height: 44px;
    font-size: 15px;
    touch-action: manipulation;
  }

  /* Reply templates dropdown becomes a bottom sheet on mobile */
  .composer .quick-menu {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.18);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 30;
  }

  .composer-disabled {
    padding: 14px 16px
      calc(14px + max(0px, env(safe-area-inset-bottom)));
    flex-wrap: wrap;
    gap: 10px;
  }
  .composer-disabled .btn {
    min-height: 42px;
    padding: 10px 18px;
  }

  /* ─── Right panel (info view) ────────────────────────── */

  .right .tabs .tab {
    padding: 14px 0;
    font-size: 12px;
    min-height: 48px;
    touch-action: manipulation;
  }
  .right .body {
    padding: 16px;
    -webkit-overflow-scrolling: touch;
  }
  .right .avatar-block {
    padding: 8px 0 16px;
  }
  .right .avatar-block .big {
    width: 72px;
    height: 72px;
    font-size: 26px;
  }
  .right .avatar-block .name {
    font-size: 17px;
  }
  .right .section-label {
    font-size: 11px;
    margin: 16px 0 8px;
  }
  .right .tag-editor .tag,
  .right .tag-editor .tag-add {
    min-height: 32px;
    font-size: 13px;
    padding: 6px 12px;
  }
  .right .tag-editor .tag-input {
    font-size: 16px;
    min-height: 32px;
  }
  .right .notes-editor textarea {
    font-size: 16px;
    min-height: 80px;
  }
  .right .kv-card {
    padding: 12px 14px;
  }
  .right .kv-card .kv-row {
    padding: 8px 0;
  }

  /* ─── Booking tab ────────────────────────────────────── */

  .booking-tab {
    padding: 0;
  }
  .booking-tab .upcoming-card,
  .current-booking-card {
    padding: 14px;
  }
  .booking-tab .qa-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .booking-tab .qa-row .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 40px;
    font-size: 12px;
    touch-action: manipulation;
  }
  .booking-tab .booking-field-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* ─── Modals ─────────────────────────────────────────── */

  .modal-backdrop {
    padding: 16px;
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
    border-radius: 16px 16px 0 0;
    margin-bottom: 0;
  }
  .modal__body {
    padding: 16px;
    -webkit-overflow-scrolling: touch;
  }
  .modal__body input,
  .modal__body select,
  .modal__body textarea {
    font-size: 16px; /* prevent iOS zoom-on-focus */
    min-height: 42px;
  }
  .modal__actions {
    padding: 12px 16px
      calc(12px + max(0px, env(safe-area-inset-bottom)));
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal__actions .btn {
    width: 100%;
    min-height: 46px;
    font-size: 14px;
  }

  /* ─── Misc touch targets ─────────────────────────────── */

  button {
    touch-action: manipulation;
  }
}
