:root {
  --bg: #07111f;
  --bg-soft: #0c1a2d;
  --panel: rgba(14, 29, 50, 0.92);
  --panel-strong: #101f35;
  --line: rgba(180, 205, 238, 0.16);
  --text: #f7fbff;
  --muted: #9fb3cc;
  --blue: #2f80ff;
  --cyan: #20d6ff;
  --orange: #ff9f1c;
  --green: #20c997;
  --pink: #ff4d8d;
  --red: #ef4444;
  --yellow: #ffd166;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

.nav-count,
.unread-count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: auto;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  font-size: 12px;
  font-weight: 800;
}

.connection-status.offline {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.14);
  color: #fcd34d;
}

.monitor-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.monitor-panel {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: min(74vh, 760px);
  min-height: 620px;
  padding: 0;
  overflow: hidden;
}

.conversation-sidebar {
  min-width: 0;
  padding: 20px;
  border-right: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(5, 15, 28, 0.78);
}

.conversation-sidebar > input {
  width: 100%;
  margin-bottom: 14px;
}

.conversation-list {
  display: grid;
  gap: 9px;
  max-height: calc(100% - 96px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.conversation-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  width: 100%;
  gap: 11px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(15, 31, 50, 0.74);
  color: #e5edf7;
  text-align: left;
  cursor: pointer;
}

.conversation-item:hover,
.conversation-item.active {
  border-color: rgba(47, 128, 255, 0.62);
  background: rgba(47, 128, 255, 0.14);
}

.conversation-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #f4c34c, #9b6b12);
  color: #07111f;
  font-weight: 900;
  overflow: hidden;
  flex: 0 0 auto;
}

.conversation-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-avatar {
  width: 46px;
  height: 46px;
}

.conversation-copy {
  min-width: 0;
}

.conversation-name,
.conversation-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conversation-name {
  justify-content: space-between;
}

.conversation-name strong,
.conversation-preview,
.conversation-phone {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-name strong {
  min-width: 0;
  color: #fff;
}

.conversation-name small,
.conversation-preview,
.conversation-phone {
  color: #8da0b7;
  font-size: 11px;
}

.conversation-phone {
  display: block;
  margin-top: 2px;
  color: #b8c7dc;
}

.conversation-preview {
  display: block;
  margin: 5px 0 8px;
}

.chat-panel {
  display: flex;
  min-width: 0;
  background:
    linear-gradient(rgba(7, 17, 31, 0.95), rgba(7, 17, 31, 0.95)),
    radial-gradient(circle at 20% 20%, rgba(47, 128, 255, 0.15), transparent 35%);
}

.chat-panel > div {
  width: 100%;
}

.chat-empty {
  display: grid;
  place-content: center;
  padding: 30px;
  color: #8da0b7;
  text-align: center;
}

.chat-empty strong {
  color: #f8fafc;
  font-size: 22px;
}

#chat-content {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  min-width: 0;
  height: 100%;
}

.chat-header {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) minmax(160px, 220px) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(5, 15, 28, 0.72);
}

.chat-client-block {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.chat-client-block strong {
  overflow: hidden;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header small,
.chat-hint,
.chat-compose-tools small {
  color: #8da0b7;
}

.attendant-field {
  display: grid;
  gap: 4px;
  margin: 0;
}

.attendant-field span {
  color: #8da0b7;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.attendant-field input {
  height: 36px;
  min-width: 0;
}

.chat-actions,
.chat-compose,
.chat-compose-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.chat-actions .btn,
.chat-actions .badge {
  min-height: 32px;
  white-space: nowrap;
}

.chat-actions .btn.success {
  min-width: 92px;
  color: #052e1c;
  font-weight: 900;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

.chat-message {
  align-self: flex-start;
  max-width: min(78%, 680px);
  padding: 10px 13px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px 14px 14px 4px;
  background: #152438;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

.chat-message.client {
  align-self: flex-start;
  border-color: rgba(32, 201, 151, 0.22);
  border-radius: 14px 14px 14px 4px;
  background: #123d34;
}

.chat-message.attendant {
  align-self: flex-end;
  border-color: rgba(47, 128, 255, 0.28);
  border-radius: 14px 14px 4px 14px;
  background: #193f74;
}

.chat-message.system,
.chat-message.bot {
  background: #152438;
}

.chat-message small {
  color: #a8b8ca;
  font-size: 10px;
}

.chat-message p {
  margin: 5px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.42;
  font-family: "Segoe UI", "Segoe UI Emoji", "Apple Color Emoji", Arial, sans-serif;
}

.message-media {
  display: grid;
  gap: 8px;
  margin-top: 7px;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.message-media span {
  color: #dce9ff;
  font-size: 12px;
  font-weight: 900;
}

.message-media audio {
  width: min(320px, 100%);
}

.message-media-link {
  display: block;
  width: min(340px, 100%);
  color: inherit;
  text-decoration: none;
}

.message-media img,
.message-media video {
  display: block;
  width: min(340px, 100%);
  max-height: 360px;
  border-radius: 8px;
  background: #0b141a;
  object-fit: contain;
}

.message-document-link {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fbff;
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.media-error-text {
  display: none;
  color: #fca5a5 !important;
}

.message-media.media-error .media-error-text {
  display: block;
}

.message-failed {
  display: block;
  margin-top: 5px;
  color: #fca5a5 !important;
}

.chat-compose-tools {
  justify-content: space-between;
  padding: 10px 20px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.chat-compose {
  padding: 10px 20px 8px;
}

.chat-compose textarea {
  flex: 1;
  min-height: 64px;
  resize: vertical;
}

.chat-hint {
  padding: 0 20px 14px;
}

.promo-broadcast-panel textarea {
  min-height: 110px;
  resize: vertical;
}

.campaign-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 14px;
}

.campaign-metrics article,
.campaign-card {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  background: rgba(8, 20, 36, 0.66);
}

.campaign-metrics article {
  min-height: 96px;
  padding: 12px;
}

.campaign-metrics small,
.campaign-funnel span {
  color: #9fb3cc;
  font-size: 12px;
}

.campaign-metrics strong {
  display: block;
  margin: 8px 0 4px;
  color: #fff;
  font-size: 28px;
}

.campaign-metrics span {
  color: #b8c7db;
  font-size: 12px;
}

.campaign-explainer {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(47, 128, 255, 0.22);
  border-radius: 10px;
  background: rgba(47, 128, 255, 0.08);
  color: #c7d7eb;
  font-size: 13px;
}

.campaign-explainer summary,
.campaign-card summary,
.campaign-message-box summary,
.campaign-media-box summary,
.campaign-recipients-box summary {
  cursor: pointer;
  list-style: none;
}

.campaign-explainer summary::-webkit-details-marker,
.campaign-card summary::-webkit-details-marker,
.campaign-message-box summary::-webkit-details-marker,
.campaign-media-box summary::-webkit-details-marker,
.campaign-recipients-box summary::-webkit-details-marker {
  display: none;
}

.campaign-explainer summary {
  display: flex;
  align-items: center;
  color: #fff;
  font-weight: 800;
}

.campaign-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.campaign-card {
  padding: 14px;
}

.campaign-card > summary,
.campaign-funnel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.campaign-card > summary {
  justify-content: space-between;
}

.campaign-card > summary::after,
.campaign-message-box summary::after,
.campaign-media-box summary::after,
.campaign-recipients-box summary::after,
.campaign-explainer summary::after {
  content: "+";
  margin-left: auto;
  color: #7dd3fc;
  font-weight: 900;
}

.campaign-card[open] > summary::after,
.campaign-message-box[open] summary::after,
.campaign-media-box[open] summary::after,
.campaign-recipients-box[open] summary::after,
.campaign-explainer[open] summary::after {
  content: "-";
}

.campaign-card h3 {
  margin: 4px 0 0;
}

.campaign-card summary p {
  max-width: 620px;
  margin: 6px 0 0;
  color: #aebed3;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-funnel {
  margin: 14px 0 12px;
}

.campaign-funnel span {
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(15, 31, 50, 0.9);
}

.campaign-card pre {
  white-space: pre-wrap;
  margin: 10px 0 12px;
  color: #dce8f7;
}

.campaign-message-box,
.campaign-media-box,
.campaign-recipients-box {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  background: rgba(3, 12, 24, 0.42);
}

.campaign-message-box summary,
.campaign-media-box summary,
.campaign-recipients-box summary {
  display: flex;
  align-items: center;
  color: #dce8f7;
  font-weight: 800;
}

.campaign-media-box img,
.campaign-media-box video {
  display: block;
  max-width: min(420px, 100%);
  max-height: 260px;
  margin-top: 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: #020817;
  object-fit: contain;
}

.campaign-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.campaign-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 13px;
}

.campaign-table th,
.campaign-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  vertical-align: top;
}

.campaign-table th {
  color: #9fb3cc;
  font-size: 11px;
  text-transform: uppercase;
}

@media (max-width: 1100px) {
  .campaign-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .campaign-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .monitor-summary,
  .monitor-panel {
    grid-template-columns: 1fr;
  }

  .monitor-panel {
    min-height: 0;
  }

  .conversation-sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  }

  .conversation-list {
    max-height: 320px;
  }

  #chat-content {
    min-height: 600px;
  }

  .chat-header,
  .chat-actions,
  .chat-compose {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-message {
    max-width: 90%;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  color: var(--text);
  font-family: "Segoe UI", "Inter", Arial, sans-serif;
  background:
    radial-gradient(circle at 12% 12%, rgba(47, 128, 255, 0.22), transparent 34%),
    radial-gradient(circle at 90% 4%, rgba(255, 159, 28, 0.18), transparent 30%),
    linear-gradient(145deg, #050b14 0%, #081527 52%, #0a1524 100%);
}

body.locked {
  overflow: hidden;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 11, 20, 0.92);
  backdrop-filter: blur(18px);
}

.login-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e1d32;
  box-shadow: var(--shadow);
}

.login-card img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
}

.login-card h1 {
  margin: 16px 0 10px;
  font-size: 26px;
}

.login-card p {
  min-height: 20px;
  margin: 12px 0 0;
  color: #fecaca;
  font-weight: 700;
}

.sidebar {
  width: 278px;
  min-height: 100vh;
  padding: 24px 18px;
  background: rgba(4, 11, 21, 0.78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 30px;
}

.brand img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(32, 214, 255, 0.2);
}

.brand strong,
.hero h1,
.panel h2,
.kpi strong {
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand small,
.sidebar-card small,
.sidebar-card p,
.hero p,
.label,
.kpi small,
.kpi span,
.mini-metrics small,
.system-grid small,
.order-meta,
.location small {
  color: var(--muted);
}

.notification-wrap {
  position: relative;
}

.sound-wrap {
  position: relative;
}

.sound-settings-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(32, 214, 255, 0.28);
  border-radius: 14px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(32, 214, 255, 0.16), rgba(32, 214, 255, 0.04)),
    var(--panel-strong);
  box-shadow: 0 12px 28px rgba(32, 214, 255, 0.1);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.sound-settings-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(32, 214, 255, 0.58);
  box-shadow: 0 18px 34px rgba(32, 214, 255, 0.15);
}

.sound-gear {
  width: 22px;
  height: 22px;
  position: relative;
  display: block;
  border: 3px solid var(--cyan);
  border-radius: 50%;
}

.sound-gear::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--cyan);
}

.sound-gear::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  width: 4px;
  height: 32px;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: -10px 10px 0 -1px var(--cyan), 10px 10px 0 -1px var(--cyan);
  transform: translateX(-50%) rotate(45deg);
}

.sound-settings-panel {
  width: min(300px, calc(100vw - 24px));
  position: absolute;
  top: 52px;
  right: 0;
  z-index: 31;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(32, 214, 255, 0.08), transparent 36%),
    #0e1d32;
  box-shadow: var(--shadow);
}

.sound-settings-panel strong {
  font-size: 15px;
}

.sound-switch,
.sound-volume-row {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.sound-switch {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.sound-switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--cyan);
}

.sound-volume-row {
  grid-template-columns: 1fr auto;
}

.sound-volume-row input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--cyan);
}

.bell-btn {
  width: 48px;
  height: 48px;
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 14px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 209, 102, 0.18), rgba(255, 209, 102, 0.04)),
    var(--panel-strong);
  box-shadow: 0 12px 28px rgba(255, 209, 102, 0.11);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.bell-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 209, 102, 0.58);
  box-shadow: 0 18px 34px rgba(255, 209, 102, 0.16);
}

.bell-icon {
  width: 22px;
  height: 24px;
  position: relative;
  display: block;
  border: 3px solid var(--yellow);
  border-bottom: 0;
  border-radius: 16px 16px 6px 6px;
}

.bell-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 30px;
  height: 8px;
  border-radius: 999px;
  background: var(--yellow);
  transform: translateX(-50%);
}

.bell-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  transform: translateX(-50%);
}

.bell-btn b {
  min-width: 20px;
  height: 20px;
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  color: #fff;
  background: var(--red);
  font-size: 11px;
  box-shadow: 0 0 0 3px #0e1d32;
}

.notification-panel {
  width: min(390px, calc(100vw - 24px));
  max-height: 430px;
  position: absolute;
  top: 52px;
  right: 0;
  z-index: 30;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(32, 214, 255, 0.06), transparent 36%),
    #0e1d32;
  box-shadow: var(--shadow);
}

.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.notification-head button {
  min-height: 34px;
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 8px;
  padding: 0 10px;
  color: #07111f;
  background: var(--yellow);
  font-weight: 800;
  cursor: pointer;
}

.notification-list {
  max-height: 360px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.notification-item {
  display: grid;
  gap: 4px;
  position: relative;
  padding: 12px 12px 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.notification-item[data-notification-tab] {
  cursor: pointer;
}

.notification-item::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 7px;
  width: 4px;
  border-radius: 999px;
  background: var(--yellow);
}

.notification-item strong {
  font-size: 14px;
}

.notification-item small {
  color: var(--muted);
}

.notification-item.ok strong {
  color: var(--green);
}

.notification-item.ok::before {
  background: var(--green);
}

.notification-item.bad strong {
  color: var(--red);
}

.notification-item.bad::before {
  background: var(--red);
}

.notification-item.warn strong {
  color: var(--yellow);
}

.notification-item.warn::before {
  background: var(--yellow);
}

.notification-item.new strong {
  color: var(--cyan);
}

.notification-item.new::before {
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(32, 214, 255, 0.45);
}

.menu {
  display: grid;
  gap: 8px;
}

.nav {
  width: 100%;
  height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  color: #cfe0f5;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: 0.18s ease;
}

.nav span {
  display: inline-flex;
  width: 34px;
  color: #5f7da4;
  font-weight: 800;
}

.nav:hover,
.nav.active {
  color: #fff;
  border-color: rgba(47, 128, 255, 0.38);
  background: linear-gradient(135deg, rgba(47, 128, 255, 0.2), rgba(32, 214, 255, 0.08));
}

.mobile-tab-select {
  display: none;
}

.sidebar-card {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 159, 28, 0.12), rgba(47, 128, 255, 0.08));
}

.sidebar-card strong {
  display: block;
  margin: 8px 0;
}

.shell {
  flex: 1;
  min-width: 0;
  padding: 28px;
}

.hero {
  min-height: 170px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 128, 255, 0.28), rgba(255, 159, 28, 0.13)),
    rgba(11, 25, 44, 0.9);
  box-shadow: var(--shadow);
}

.eyebrow,
.label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--yellow);
  margin-bottom: 10px;
}

.hero h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
}

.hero p {
  margin: 10px 0 0;
  max-width: 620px;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.status {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
}

.status.open {
  color: #052e1c;
  background: linear-gradient(135deg, #4ade80, #20c997);
}

.status.closed {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #ff4d8d);
}

.tab {
  display: none;
  margin-top: 22px;
}

.tab.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid.short {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.kpi,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
}

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 18px;
}

.kpi-eye {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 0;
  color: #dbeafe;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  z-index: 2;
}

.kpi-eye::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 7px auto;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.kpi-eye.off::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 16px;
  height: 2px;
  background: currentColor;
  transform: rotate(-35deg);
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto -24px -34px auto;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  opacity: 0.2;
  background: currentColor;
}

.kpi.blue { color: var(--cyan); }
.kpi.orange { color: var(--orange); }
.kpi.green { color: var(--green); }
.kpi.pink { color: var(--pink); }

.kpi strong {
  display: block;
  margin: 10px 0 4px;
  padding-right: 34px;
  color: #fff;
  font-size: 27px;
}

.overview-grid,
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.two-col {
  margin-bottom: 18px;
}

.two-col.wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-title .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.search-input {
  width: 100%;
  margin: 0 0 14px;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.diagnostic-item {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.28);
}

.diagnostic-item small {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.diagnostic-item.ok strong {
  color: var(--green);
}

.diagnostic-item.warn strong {
  color: var(--yellow);
}

.diagnostic-alerts {
  display: grid;
  gap: 10px;
}

.diagnostic-alert {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.28);
}

.diagnostic-alert span {
  color: var(--muted);
  line-height: 1.45;
}

.diagnostic-alert.warn {
  border-left-color: var(--yellow);
}

.diagnostic-alert.bad {
  border-left-color: var(--red);
}

.diagnostic-alert.bad strong {
  color: var(--red);
}

.diagnostic-alert.warn strong {
  color: var(--yellow);
}

.diagnostic-alert.ok strong {
  color: var(--green);
}

/* Monitoramento inspirado no fluxo do WhatsApp, com perfil e organização. */
.monitor-panel {
  position: relative;
}

.conversation-sidebar {
  padding: 14px;
}

.conversation-sidebar .panel-title {
  margin-bottom: 10px;
}

.conversation-sidebar > input {
  height: 40px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 8px;
  background: #1f2c34;
}

.conversation-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.conversation-filters button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: transparent;
  color: #aebac1;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.conversation-filters button.active {
  border-color: rgba(37, 211, 102, 0.5);
  background: rgba(37, 211, 102, 0.14);
  color: #7ee2a8;
}

.conversation-list {
  gap: 0;
  max-height: calc(100% - 132px);
  padding-right: 0;
}

.conversation-item {
  grid-template-columns: 48px minmax(0, 1fr);
  min-height: 76px;
  gap: 11px;
  padding: 11px 8px;
  border: 0;
  border-bottom: 1px solid rgba(134, 150, 160, 0.13);
  border-radius: 0;
  background: transparent;
}

.conversation-item:hover,
.conversation-item.active {
  border-color: rgba(134, 150, 160, 0.13);
  background: #202c33;
}

.conversation-item .conversation-avatar {
  width: 48px;
  height: 48px;
  background: #6a7175;
  color: #f0f2f5;
}

.conversation-name strong {
  font-size: 14px;
  font-weight: 650;
}

.conversation-pin {
  margin-right: 6px;
  color: #25d366;
  font-size: 8px;
  vertical-align: 2px;
}

.conversation-state {
  color: #7ee2a8 !important;
  font-weight: 700;
}

.chat-panel {
  background: #0b141a;
}

.chat-header {
  background: #202c33;
}

.chat-profile-button,
.chat-client-block {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.chat-profile-button {
  display: grid;
  place-items: center;
}

.chat-client-block:hover strong {
  color: #7ee2a8;
}

.chat-message {
  border: 0;
  border-radius: 8px 8px 8px 2px;
  background: #202c33;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
}

.chat-message.client {
  border: 0;
  border-radius: 8px 8px 8px 2px;
  background: #202c33;
}

.chat-message.attendant,
.chat-message.bot {
  align-self: flex-end;
  border: 0;
  border-radius: 8px 8px 2px 8px;
  background: #005c4b;
}

.chat-message.system {
  align-self: center;
  max-width: 90%;
  background: #182229;
  color: #d1d7db;
  text-align: center;
}

.chat-compose,
.chat-compose-tools {
  background: #202c33 !important;
}

.chat-compose textarea {
  border: 0 !important;
  border-radius: 8px;
  background: #2a3942 !important;
}

.contact-profile {
  position: absolute;
  z-index: 30;
  top: 0;
  right: 0;
  width: min(360px, 92%);
  height: 100%;
  border-left: 1px solid rgba(134, 150, 160, 0.2);
  background: #111b21;
  box-shadow: -18px 0 45px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
}

.contact-profile header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 18px;
  background: #202c33;
}

.profile-close {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  background: transparent;
  color: #d1d7db;
  font-size: 25px;
  cursor: pointer;
}

.contact-profile-body {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 20px;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  margin-bottom: 6px;
  background: #6a7175;
  color: #f0f2f5;
  font-size: 34px;
}

.contact-profile h3 {
  margin: 0;
  color: #f0f2f5;
  font-size: 21px;
}

.contact-profile a {
  color: #8696a0;
  text-decoration: none;
}

.contact-profile dl {
  display: grid;
  width: 100%;
  gap: 1px;
  margin: 22px 0 0;
}

.contact-profile dl div {
  padding: 14px 12px;
  background: #182229;
}

.contact-profile dt {
  margin-bottom: 5px;
  color: #25d366;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.contact-profile dd {
  margin: 0;
  color: #d1d7db;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .contact-profile {
    position: fixed;
    top: 0;
    bottom: 0;
    height: 100vh;
  }
}

/* Posicionamento final do cabeçalho após adicionar o botão de perfil. */
.monitor-panel.chat-open .chat-profile-button {
  grid-column: 2;
  grid-row: 1;
}

.monitor-panel.chat-open .chat-avatar {
  grid-column: auto;
}

.monitor-panel.chat-open .chat-actions {
  gap: 6px;
}

.monitor-panel.chat-open .chat-actions .btn {
  min-width: auto;
  padding-inline: 10px;
}

@media (max-width: 1180px) {
  .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .monitor-panel.chat-open .attendant-field,
  .monitor-panel.chat-open .chat-actions {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

/* Acabamento minimalista dos filtros do monitoramento. */
.conversation-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin: 0 0 12px;
  overflow: visible;
  scrollbar-width: none;
}

.conversation-filters::-webkit-scrollbar {
  display: none;
}

.conversation-filters button {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
  color: #9eacb7;
  font-size: 12px;
}

.conversation-filters button:hover {
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: #e5edf3;
}

.conversation-filters button.active {
  border-color: rgba(37, 211, 102, 0.28);
  background: rgba(37, 211, 102, 0.1);
  color: #72d99a;
  box-shadow: inset 0 0 0 1px rgba(37, 211, 102, 0.04);
}

.conversation-sidebar {
  border-right-color: rgba(148, 163, 184, 0.1);
}

/* Aplicativo móvel para iPhone. */
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overscroll-behavior-y: none;
  }

  body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 46%);
    align-items: center;
    gap: 10px;
    padding: max(8px, env(safe-area-inset-top)) 12px 9px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(4, 11, 21, 0.98);
    backdrop-filter: blur(16px);
  }

  .brand {
    min-width: 0;
    margin: 0;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .brand strong {
    display: block;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-tab-select {
    min-height: 40px;
    margin: 0;
    padding: 0 34px 0 10px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 7px;
    background-color: #111f2d;
    font-size: 14px;
  }

  .shell {
    padding: 10px 10px calc(18px + env(safe-area-inset-bottom));
  }

  .hero {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
    padding: 11px 12px;
    border-radius: 8px;
  }

  .hero h1 {
    font-size: 17px;
  }

  .hero-actions {
    grid-template-columns: 42px 42px minmax(0, 1fr) minmax(0, 1fr);
    gap: 7px;
  }

  .bell-btn,
  .sound-settings-btn {
    min-width: 42px;
  }

  .hero-actions > .status,
  .connection-status {
    min-width: 0;
    padding: 0 7px;
    font-size: 11px;
    text-align: center;
  }

  #refresh-btn {
    grid-column: 1 / 4;
    min-height: 42px;
  }

  .hero-actions > .logout-btn {
    grid-column: 4;
    min-height: 42px;
  }

  .kpi-grid,
  .kpi-grid.short,
  .monitor-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
  }

  .kpi {
    min-height: 112px;
    padding: 13px;
  }

  .kpi small {
    min-height: 30px;
    line-height: 1.3;
  }

  .kpi strong {
    font-size: 25px;
  }

  .panel {
    margin-bottom: 10px;
    padding: 12px;
  }

  .panel-title {
    align-items: stretch;
  }

  .panel-title .actions,
  .quick-grid,
  .order-actions,
  .manual-address-tools,
  .motoboy-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .panel-title .actions .btn,
  .quick-grid .btn,
  .order-actions .btn {
    width: 100%;
    min-height: 42px;
  }

  .monitor-panel {
    min-height: calc(100dvh - 235px);
    height: auto;
    padding: 0;
  }

  .conversation-sidebar {
    padding: 12px;
  }

  .conversation-list {
    max-height: calc(100dvh - 405px);
    min-height: 280px;
  }

  .monitor-panel.chat-open {
    min-height: calc(100dvh - 210px);
  }

  .monitor-panel.chat-open #chat-content {
    min-height: calc(100dvh - 210px);
  }

  .monitor-panel.chat-open .chat-header {
    padding: 9px;
  }

  .monitor-panel.chat-open .chat-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .monitor-panel.chat-open .chat-actions .badge {
    grid-column: 1 / -1;
    max-width: none;
    justify-content: center;
  }

  .monitor-panel.chat-open .chat-actions .btn {
    width: 100%;
    min-height: 38px;
  }

  .chat-messages {
    padding: 10px;
  }

  .chat-message,
  .monitor-panel.chat-open .chat-message {
    max-width: 90%;
    font-size: 14px;
  }

  .chat-compose {
    gap: 7px;
    padding: 8px 9px calc(9px + env(safe-area-inset-bottom));
  }

  .chat-compose textarea {
    min-height: 52px;
    max-height: 110px;
    resize: none;
  }

  .chat-compose .btn {
    min-width: 78px;
  }

  .system-grid > div,
  .diagnostic-item {
    min-width: 0;
  }

  .diagnostic-grid {
    grid-template-columns: 1fr;
  }

  .notification-panel,
  .sound-settings-panel {
    top: calc(64px + env(safe-area-inset-top));
    max-height: calc(100dvh - 84px - env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  table {
    min-width: 640px;
  }

  .table-wrap,
  .document-item,
  .order-list {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (display-mode: standalone) and (max-width: 700px) {
  .sidebar {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .shell {
    padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }
}

.panel h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.pill {
  border-radius: 8px;
  padding: 8px 10px;
  color: #07111f;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  font-size: 13px;
}

.weekly-chart {
  height: 260px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 10px;
  padding: 16px 8px 0;
  border-radius: 8px;
  background: rgba(4, 11, 21, 0.45);
}

.bar-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.bar {
  width: 100%;
  min-height: 10px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
  box-shadow: 0 12px 30px rgba(47, 128, 255, 0.28);
}

.bar.orange {
  background: linear-gradient(180deg, var(--yellow), var(--orange));
}

.bar.green {
  background: linear-gradient(180deg, #65f3bf, var(--green));
}

.bar-label,
.bar-value {
  font-size: 12px;
  color: var(--muted);
}

.ranking-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.rank-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.rank-row b {
  color: var(--yellow);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
}

.mini-metrics {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.mini-metrics div,
.system-grid div,
.location {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.location iframe {
  width: 100%;
  height: 210px;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.admin-map {
  width: 100%;
  height: 230px;
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e7eb;
}

.leaflet-control-attribution {
  display: none;
}

.moto-marker {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid #fff;
  color: #1a73e8;
  background: #fff;
  box-shadow: 0 3px 10px rgba(60, 64, 67, 0.34);
}

.moto-marker svg {
  width: 30px;
  height: 30px;
}

.motoboy-list {
  display: grid;
  gap: 10px;
}

.delivery-ranking {
  display: grid;
  gap: 10px;
}

.rank-driver {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.rank-driver b {
  min-width: 92px;
  border-radius: 8px;
  padding: 8px 10px;
  color: #07111f;
  background: var(--yellow);
  text-align: center;
}

.motoboy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.driver-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.driver-line img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 2px solid rgba(255, 255, 255, 0.45);
}

.driver-status {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  color: #07111f;
}

.driver-status.online {
  background: var(--green);
}

.driver-status.offline,
.driver-status.pending {
  background: var(--yellow);
}

.driver-status.blocked {
  color: #fff;
  background: var(--red);
}

.motoboy strong,
.motoboy small {
  display: block;
}

.motoboy-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-metrics strong,
.system-grid strong {
  display: block;
  margin-top: 5px;
}

.btn,
.link-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn.primary {
  background: linear-gradient(135deg, var(--blue), #6a5cff);
}

.btn.success {
  background: linear-gradient(135deg, #13b981, var(--green));
}

.btn.warning {
  color: #231609;
  background: linear-gradient(135deg, #ffd166, #f59e0b);
}

.btn.danger {
  background: linear-gradient(135deg, #ff4d4f, #c9184a);
}

.btn.light {
  color: #dce9ff;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
}

.btn.ghost {
  color: #dce9ff;
  background: rgba(20, 34, 56, 0.92);
  border-color: rgba(180, 205, 238, 0.32);
}

.btn.ghost:hover {
  background: rgba(32, 214, 255, 0.14);
  border-color: rgba(32, 214, 255, 0.46);
}

.btn.ghost:disabled,
.btn.light:disabled,
.btn.primary:disabled,
.btn.success:disabled,
.btn.warning:disabled,
.btn.danger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.btn.full {
  width: 100%;
  margin-top: 14px;
}

.btn.compact,
.logout-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: 7px;
}

.logout-btn {
  flex: 0 0 auto;
  min-width: 62px;
}

.btn.compact {
  min-height: 34px;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: #dbeafe;
  font-weight: 700;
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  height: 44px;
  border: 1px solid rgba(180, 205, 238, 0.22);
  border-radius: 8px;
  padding: 0 12px;
  color: #fff;
  background: rgba(5, 13, 25, 0.72);
  outline: none;
}

textarea {
  min-height: 70px;
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.35;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(32, 214, 255, 0.13);
}

.field-hint {
  display: block;
  min-height: 18px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field-hint.ok {
  color: #bbf7d0;
}

select option {
  color: #101828;
}

.form-grid,
.system-grid,
.manual-grid,
.document-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.manual-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  align-items: start;
}

.span-2 {
  grid-column: span 2;
}

.promo-grid {
  align-items: end;
}

.check-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.qty-input {
  padding-right: 8px;
}

.checkline {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(180, 205, 238, 0.22);
  border-radius: 8px;
  background: rgba(5, 13, 25, 0.42);
}

.checkline input {
  width: 18px;
  height: 18px;
}

.compact-check {
  min-height: 34px;
  width: fit-content;
  margin-top: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.compact-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.manual-address-book {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(180, 205, 238, 0.18);
  border-radius: 8px;
  background: rgba(5, 13, 25, 0.36);
}

.manual-address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.manual-address-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.manual-address-tools .btn,
.manual-address-row .btn {
  min-height: 38px;
  padding-inline: 12px;
}

.address-lines {
  display: grid;
  grid-template-columns: minmax(90px, 150px) minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.clearable-field {
  position: relative;
}

.clearable-field input {
  padding-right: 38px;
}

.field-clear {
  position: absolute;
  top: 50%;
  right: 9px;
  width: 24px;
  height: 24px;
  transform: translateY(-50%);
  border: 1px solid rgba(180, 205, 238, 0.24);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #dbeafe;
  font-size: 17px;
  font-weight: 900;
  line-height: 20px;
  cursor: pointer;
}

.field-clear:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.address-helper {
  display: grid;
  grid-template-columns: minmax(150px, 220px) auto minmax(180px, 1fr);
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}

.address-helper label {
  margin-top: 0;
}

.address-helper .field-hint {
  align-self: center;
  margin-top: 0;
}

.address-tools {
  margin-top: 8px;
}

.signature-config {
  display: grid;
  grid-template-columns: 180px minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.signature-config img {
  width: 180px;
  height: 58px;
  object-fit: contain;
  border: 1px solid rgba(180, 205, 238, 0.22);
  border-radius: 8px;
  background: #fff;
}

.document-grid {
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  align-items: start;
}

.document-items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.document-items-head h3 {
  margin: 0;
}

.document-items {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}

.document-item {
  display: grid;
  grid-template-columns: 88px minmax(180px, 1fr) 90px 80px 120px 38px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid rgba(180, 205, 238, 0.18);
  border-radius: 8px;
  background: rgba(5, 13, 25, 0.36);
}

.document-item label {
  margin-top: 0;
}

.manual-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.manual-actions strong {
  color: var(--yellow);
}

.catalog-image-preview {
  min-height: 96px;
  display: flex;
  align-items: end;
}

.catalog-image-preview img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 1px solid rgba(180, 205, 238, 0.22);
  border-radius: 8px;
  background: rgba(5, 13, 25, 0.72);
}

.catalog-image-preview.compact {
  min-height: 78px;
  margin-top: 8px;
  align-items: center;
}

.catalog-image-preview.compact img {
  width: 72px;
  height: 72px;
  display: none;
}

.panel-hint {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.water-stock-list {
  display: grid;
  gap: 8px;
}

.stock-summary {
  min-height: 50px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(32, 214, 255, 0.2);
  border-radius: 8px;
  color: #dce9ff;
  background: rgba(32, 214, 255, 0.08);
}

.stock-summary strong {
  color: var(--cyan);
  font-size: 18px;
}

.stock-summary span {
  color: var(--muted);
}

.stock-row {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.stock-row.unavailable {
  background: rgba(255, 209, 102, 0.07);
  border-color: rgba(255, 209, 102, 0.24);
}

.stock-main,
.stock-side {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stock-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #052e1c;
  background: rgba(32, 201, 151, 0.95);
  font-size: 12px;
  font-weight: 900;
}

.stock-row.unavailable .stock-icon {
  color: #2b1900;
  background: var(--yellow);
}

.stock-main strong,
.stock-main span {
  display: block;
}

.stock-main strong {
  color: #fff;
  font-size: 15px;
}

.stock-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.stock-chip {
  min-width: 94px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.stock-chip.on {
  color: #052e1c;
  background: rgba(32, 201, 151, 0.94);
}

.stock-chip.off {
  color: #2b1900;
  background: var(--yellow);
}

.stock-action {
  min-width: 92px;
}

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search-row input {
  max-width: 440px;
}

.order-list,
.location-list {
  display: grid;
  gap: 10px;
}

.order {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.order header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.order-badges,
.order-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-actions {
  margin-top: 12px;
}

.order-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.order strong,
.location strong {
  color: #fff;
}

.order pre {
  white-space: pre-wrap;
  margin: 10px 0 0;
  color: #c8d8ec;
  font-family: inherit;
}

.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  color: #07111f;
  background: var(--yellow);
}

.badge.ok {
  color: #052e1c;
  background: var(--green);
}

.badge.warn {
  color: #2b1900;
  background: var(--yellow);
}

.badge.edited {
  color: #2b1900;
  background: var(--yellow);
}

.badge.bad {
  color: #fff;
  background: var(--red);
}

.badge.danger {
  color: #fff;
  background: var(--red);
}

.cancelled-document {
  border-color: rgba(255, 75, 92, 0.5);
  opacity: 0.86;
}

.cancelled-document pre,
.cancelled-document .order-meta {
  color: #fca5a5;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 380px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #081527;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

@media (max-width: 1040px) {
  body {
    display: block;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: static;
    padding: 16px;
  }

  .brand {
    margin-bottom: 14px;
  }

  .menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .nav {
    min-height: 46px;
    padding: 10px 12px;
  }

  .sidebar-card {
    margin-top: 14px;
  }

  .kpi-grid,
  .kpi-grid.short,
  .overview-grid,
  .two-col,
  .two-col.wide-left,
    .form-grid,
    .manual-grid,
    .document-grid,
    .system-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .signature-config {
    grid-template-columns: 1fr;
  }

  .address-helper {
    grid-template-columns: 1fr;
  }

  .manual-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero,
  .panel-title {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    justify-content: stretch;
  }

  .hero-actions > .btn:not(.logout-btn),
  .hero-actions > .status {
    flex: 1 1 150px;
    justify-content: center;
  }

  .hero-actions > .logout-btn {
    flex: 0 0 72px;
  }
}

@media (max-width: 520px) {
  .stock-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .stock-side {
    justify-content: space-between;
  }

  .stock-action {
    min-width: 110px;
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    min-width: 0;
    background: #07111f;
  }

  .login-screen {
    padding: 14px;
    align-items: start;
    padding-top: max(18px, env(safe-area-inset-top));
  }

  .login-card {
    padding: 18px;
  }

  .login-card h1 {
    font-size: 24px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: max(10px, env(safe-area-inset-top)) 10px 10px;
    background: rgba(4, 11, 21, 0.96);
  }

  .brand {
    gap: 10px;
    margin-bottom: 10px;
  }

  .brand img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
  }

  .brand strong {
    font-size: 13px;
  }

  .brand small,
  .sidebar-card {
    display: none;
  }

  .menu {
    display: none;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .menu::-webkit-scrollbar {
    display: none;
  }

  .nav {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 9px 12px;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .nav span {
    display: none;
  }

  .mobile-tab-select {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 8px;
    border-color: rgba(47, 128, 255, 0.42);
    background: #07111f;
    color: #fff;
    font-weight: 800;
  }

  .shell {
    width: 100%;
    min-width: 0;
    padding: 12px 10px max(20px, env(safe-area-inset-bottom));
  }

  .hero {
    gap: 12px;
    padding: 14px;
  }

  .hero p,
  .eyebrow {
    display: none;
  }

  .hero h1 {
    font-size: 20px;
    line-height: 1.15;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .notification-wrap,
  .sound-wrap,
  .hero-actions > .status,
  .hero-actions > .btn {
    width: 100%;
  }

  .bell-btn,
  .sound-settings-btn,
  .hero-actions > .status,
  .hero-actions > .btn {
    min-height: 40px;
  }

  #refresh-btn {
    grid-column: span 2;
  }

  .hero-actions > .logout-btn {
    min-width: 0;
  }

  .panel,
  .kpi,
  .order,
  .task-card,
  .document-card {
    border-radius: 8px;
  }

  .panel {
    padding: 14px;
  }

  .kpi-grid,
  .kpi-grid.short {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .two-col,
  .two-col.wide-left,
  .overview-grid,
  .manual-grid,
  .document-grid,
  .form-grid,
  .system-grid,
  .address-lines,
  .address-helper,
  .manual-actions {
    grid-template-columns: 1fr;
  }

  input,
  textarea,
  select,
  button {
    max-width: 100%;
  }

  input,
  textarea,
  select {
    min-height: 44px;
    font-size: 16px;
  }

  .order,
  .task-card,
  .document-card {
    overflow-wrap: anywhere;
  }

  .order header,
  .panel-title,
  .manual-actions {
    gap: 10px;
  }

  .filter-row,
  .search-row,
  .manual-address-row,
  .document-item {
    display: grid;
    grid-template-columns: 1fr;
  }

  .document-item {
    overflow-x: auto;
  }

  .notification-panel,
  .sound-settings-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    top: calc(72px + env(safe-area-inset-top));
    width: auto;
    max-width: none;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    max-width: none;
  }
}
/* Monitoramento profissional: evita cortes no aplicativo WebView e mantem a resposta visivel. */
.monitor-panel {
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  height: clamp(540px, calc(100vh - 350px), 700px);
  min-height: 0;
}

.chat-header {
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px 12px;
  padding: 12px 16px;
}

.chat-back {
  grid-column: 1;
  grid-row: 1;
}

.chat-avatar {
  grid-column: 2;
  grid-row: 1;
}

.chat-client-block {
  grid-column: 3;
  grid-row: 1;
}

.attendant-field {
  grid-column: 1 / -1;
  grid-row: 2;
  max-width: 280px;
}

.chat-actions {
  grid-column: 1 / -1;
  grid-row: 3;
  justify-content: flex-start;
}

.chat-actions .badge {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-messages {
  padding: 16px;
}

.chat-compose-tools {
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px 0;
}

.chat-compose {
  align-items: stretch;
  padding: 10px 16px 8px;
}

.chat-compose textarea {
  min-height: 76px;
}

.chat-compose .btn {
  min-width: 104px;
}

@media (max-width: 1180px) {
  .monitor-panel {
    grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  }

  .conversation-sidebar {
    padding: 16px;
  }

  .chat-message {
    max-width: 92%;
  }
}

@media (max-width: 980px) {
  .monitor-panel {
    grid-template-columns: 1fr;
    height: auto;
  }

  .conversation-list {
    max-height: 260px;
  }

  #chat-content {
    min-height: 560px;
  }
}
/* Monitoramento fixo: compositor sempre visivel e botoes mais nitidos. */
.btn,
.link-button,
button {
  text-shadow: none !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.btn,
.link-button {
  font-weight: 750;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}

.quick-grid .btn {
  min-height: 44px;
  padding: 0 12px;
  font-size: 15px;
}

.btn.compact,
.logout-btn {
  font-weight: 750;
  line-height: 1.1;
}

.monitor-panel {
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  height: clamp(430px, calc(100vh - 300px), 620px);
  min-height: 0;
}

.conversation-sidebar,
.chat-panel,
#chat-content {
  min-height: 0;
}

#chat-content {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: 100%;
  overflow: hidden;
}

.chat-header {
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px 12px;
  padding: 10px 16px;
}

.chat-back {
  grid-column: 1;
  grid-row: 1;
}

.chat-avatar {
  grid-column: 2;
  grid-row: 1;
}

.chat-client-block {
  grid-column: 3;
  grid-row: 1;
}

.attendant-field {
  grid-column: 1 / -1;
  grid-row: 2;
  max-width: 280px;
  margin-top: 2px;
}

.chat-actions {
  grid-column: 1 / -1;
  grid-row: 3;
  justify-content: flex-start;
}

.chat-actions .badge {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-messages {
  min-height: 0;
  max-height: none;
  padding: 14px 16px;
  overflow-y: auto;
}

.chat-message {
  max-width: min(92%, 620px);
}

.chat-compose-tools {
  flex-wrap: wrap;
  padding: 8px 16px 0;
  background: rgba(5, 15, 28, 0.96);
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.chat-compose-tools small {
  display: none;
}

.chat-compose {
  align-items: stretch;
  padding: 8px 16px 12px;
  background: rgba(5, 15, 28, 0.96);
}

.chat-compose textarea {
  min-height: 82px;
  max-height: 140px;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(180, 205, 238, 0.28);
  color: #fff;
}

.chat-compose textarea:disabled {
  opacity: 0.62;
}

.chat-compose .btn {
  min-width: 104px;
}

.chat-hint {
  display: none;
}

@media (max-width: 1180px) {
  .monitor-panel {
    grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
    height: clamp(420px, calc(100vh - 285px), 600px);
  }

  .conversation-sidebar {
    padding: 16px;
  }
}

@media (max-width: 980px) {
  .monitor-panel {
    grid-template-columns: 1fr;
    height: auto;
  }

  .conversation-list {
    max-height: 240px;
  }

  #chat-content {
    min-height: 520px;
  }
}
/* Monitor pro7: conversa em foco, valores privados e botoes nitidos. */
.btn,
.link-button,
button {
  text-shadow: none !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.btn,
.link-button {
  font-weight: 700;
  letter-spacing: 0;
}

.btn.success {
  color: #052e1c;
}

.quick-grid .btn {
  min-height: 44px;
  font-size: 15px;
}

.monitor-panel.chat-open {
  grid-template-columns: minmax(0, 1fr);
}

.monitor-panel.chat-open .conversation-sidebar {
  display: none;
}

.monitor-panel.chat-open .chat-message {
  max-width: min(84%, 720px);
}

.monitor-panel.chat-open .chat-header {
    grid-template-columns: auto auto minmax(0, 1fr) minmax(180px, 280px) auto;
  align-items: center;
}

.monitor-panel.chat-open .chat-back,
.monitor-panel.chat-open .chat-avatar,
.monitor-panel.chat-open .chat-client-block,
.monitor-panel.chat-open .attendant-field,
.monitor-panel.chat-open .chat-actions {
  grid-row: 1;
}

.monitor-panel.chat-open .chat-back {
    grid-column: 1;
  }
  
.monitor-panel.chat-open .chat-avatar {
    grid-column: 2;
  }

.monitor-panel.chat-open .chat-client-block {
    grid-column: 3;
  }
  
.monitor-panel.chat-open .attendant-field {
    grid-column: 4;
  max-width: none;
  margin: 0;
}

.monitor-panel.chat-open .chat-actions {
    grid-column: 5;
  justify-content: flex-end;
}

.kpi strong[data-hidden="true"] {
  letter-spacing: 1px;
}

@media (max-width: 980px) {
  .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .monitor-panel.chat-open .attendant-field,
  .monitor-panel.chat-open .chat-actions {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (min-width: 981px) and (max-width: 1180px) {
  .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .monitor-panel.chat-open .attendant-field,
  .monitor-panel.chat-open .chat-actions {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

.monitor-panel.chat-open .chat-header {
  grid-template-columns: auto auto minmax(0, 1fr);
}

.monitor-panel.chat-open .chat-back {
  grid-column: 1;
  grid-row: 1;
}

.monitor-panel.chat-open .chat-profile-button {
  grid-column: 2;
  grid-row: 1;
}

.monitor-panel.chat-open .chat-client-block {
  grid-column: 3;
  grid-row: 1;
}

.monitor-panel.chat-open .attendant-field {
  grid-column: 1 / 3;
  grid-row: 2;
  width: 280px;
  max-width: 100%;
}

.monitor-panel.chat-open .chat-actions {
  grid-column: 3;
  grid-row: 2;
  justify-content: flex-end;
}

@media (max-width: 1180px) {
  .monitor-panel.chat-open .attendant-field,
  .monitor-panel.chat-open .chat-actions {
    grid-column: 1 / -1;
  }

  .monitor-panel.chat-open .chat-actions {
    grid-row: 3;
    justify-content: flex-start;
  }
}

/* iPhone: monitoramento compacto e harmonico. */
@media (max-width: 700px) {
  #monitor {
    display: none;
  }

  #monitor.active {
    display: block;
  }

  #monitor .monitor-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 8px;
  }

  #monitor .kpi {
    min-height: 74px;
    padding: 9px 8px;
    border-radius: 7px;
  }

  #monitor .kpi::after {
    width: 42px;
    height: 42px;
    opacity: 0.45;
  }

  #monitor .kpi small {
    min-height: 0;
    font-size: 10px;
    line-height: 1.18;
  }

  #monitor .kpi strong {
    margin-top: 6px;
    font-size: 22px;
    line-height: 1;
  }

  #monitor .kpi span {
    display: none;
  }

  #monitor .monitor-panel {
    min-height: calc(100dvh - 205px);
    height: calc(100dvh - 205px);
    border-radius: 8px;
    background: #0b141a;
    overflow: hidden;
  }

  #monitor .conversation-sidebar {
    height: 100%;
    padding: 10px;
    border: 0;
    background: #0b141a;
  }

  #monitor .conversation-sidebar .panel-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
  }

  #monitor .conversation-sidebar .label {
    display: none;
  }

  #monitor .conversation-sidebar h2 {
    margin: 0;
    font-size: 18px;
  }

  #monitor-refresh {
    min-height: 34px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 12px;
  }

  #monitor-search {
    height: 38px;
    min-height: 38px;
    margin-bottom: 8px;
    border-radius: 7px;
    font-size: 15px;
  }

  #monitor .conversation-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 8px;
  }

  #monitor .conversation-filters button {
    min-height: 30px;
    padding: 0 4px;
    border-radius: 6px;
    font-size: 10px;
    line-height: 1.1;
  }

  #monitor .conversation-list {
    min-height: 0;
    max-height: calc(100% - 120px);
    overflow-y: auto;
  }

  #monitor .conversation-item {
    grid-template-columns: 40px minmax(0, 1fr);
    min-height: 62px;
    gap: 9px;
    padding: 8px 4px;
  }

  #monitor .conversation-item .conversation-avatar {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }

  #monitor .conversation-name strong {
    font-size: 13px;
  }

  #monitor .conversation-name small,
  #monitor .conversation-preview,
  #monitor .conversation-phone {
    font-size: 10px;
  }

  #monitor .conversation-preview {
    margin: 3px 0 5px;
  }

  #monitor .conversation-meta .badge {
    min-height: 20px;
    padding: 0 6px;
    font-size: 10px;
  }

  #monitor .chat-panel {
    min-height: 100%;
    background: #0b141a;
  }

  #monitor .chat-empty {
    min-height: calc(100dvh - 230px);
    padding: 20px;
  }

  #monitor .chat-empty strong {
    font-size: 18px;
  }

  #monitor .chat-empty p {
    max-width: 260px;
    margin: 8px auto 0;
    font-size: 13px;
    line-height: 1.35;
  }

  #monitor .monitor-panel.chat-open,
  #monitor .monitor-panel.chat-open #chat-content {
    min-height: calc(100dvh - 118px);
    height: calc(100dvh - 118px);
  }

  #monitor .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto 34px minmax(0, 1fr);
    gap: 7px;
    padding: 7px 8px;
  }

  #monitor .chat-back {
    min-height: 34px;
    padding: 0 9px;
    font-size: 12px;
  }

  #monitor .chat-avatar {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  #monitor .chat-client-block strong {
    font-size: 14px;
  }

  #monitor .chat-client-block small {
    font-size: 10px;
  }

  #monitor .monitor-panel.chat-open .attendant-field {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-width: none;
  }

  #monitor .attendant-field span {
    display: none;
  }

  #monitor .attendant-field input {
    height: 34px;
    min-height: 34px;
    font-size: 14px;
  }

  #monitor .monitor-panel.chat-open .chat-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  #monitor .monitor-panel.chat-open .chat-actions .badge {
    grid-column: 1 / -1;
    min-height: 25px;
    border-radius: 6px;
    font-size: 11px;
  }

  #monitor .monitor-panel.chat-open .chat-actions .btn {
    min-height: 32px;
    padding: 0 5px;
    border-radius: 6px;
    font-size: 11px;
  }

  #monitor .chat-messages {
    padding: 9px;
    gap: 7px;
  }

  #monitor .chat-message,
  #monitor .monitor-panel.chat-open .chat-message {
    max-width: 88%;
    padding: 7px 9px;
    border-radius: 7px 7px 7px 2px;
    font-size: 13px;
  }

  #monitor .chat-message.attendant,
  #monitor .chat-message.bot {
    border-radius: 7px 7px 2px 7px;
  }

  #monitor .chat-message small {
    font-size: 9px;
  }

  #monitor .chat-message p {
    margin-top: 4px;
    line-height: 1.32;
  }

  #monitor .message-media {
    gap: 5px;
    padding: 6px 7px;
    border-radius: 6px;
  }

  #monitor .chat-compose-tools {
    padding: 6px 8px 0;
  }

  #monitor .chat-compose-tools .btn {
    min-height: 30px;
    padding: 0 8px;
    font-size: 11px;
  }

  #monitor .chat-compose {
    gap: 6px;
    padding: 7px 8px calc(8px + env(safe-area-inset-bottom));
  }

  #monitor .chat-compose textarea {
    min-height: 44px;
    max-height: 88px;
    border-radius: 8px;
    font-size: 15px;
  }

  #monitor .chat-compose .btn {
    min-width: 64px;
    min-height: 44px;
    border-radius: 8px;
    font-size: 12px;
  }

  #monitor .contact-profile {
    width: 100%;
  }

  #monitor .contact-profile header {
    min-height: 50px;
  }

  #monitor .contact-profile-body {
    padding: 18px 16px;
  }

  #monitor .profile-avatar {
    width: 74px;
    height: 74px;
    font-size: 26px;
  }
}

/* Monitor final polish: readable WhatsApp-like chat, desktop and iPhone. */
#monitor .monitor-panel {
  color: #eaf2fb;
}

#monitor .conversation-list,
#monitor .chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

#monitor .conversation-item {
  align-items: center;
  border: 1px solid transparent;
}

#monitor .conversation-item.active {
  border-color: rgba(52, 211, 153, 0.32);
  box-shadow: inset 3px 0 0 rgba(52, 211, 153, 0.85);
}

#monitor .conversation-copy,
#monitor .conversation-name,
#monitor .conversation-meta,
#monitor .chat-client-block {
  min-width: 0;
}

#monitor .conversation-name {
  gap: 10px;
}

#monitor .conversation-name strong,
#monitor .conversation-preview,
#monitor .conversation-phone,
#monitor .chat-client-block strong,
#monitor .chat-client-block small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#monitor .conversation-preview {
  color: #aab8c8;
  line-height: 1.32;
}

#monitor .conversation-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

#monitor .chat-messages {
  align-content: start;
  background:
    linear-gradient(180deg, rgba(8, 18, 30, 0.94), rgba(6, 16, 25, 0.98)),
    radial-gradient(circle at 20% 0%, rgba(20, 184, 166, 0.08), transparent 30%);
  overscroll-behavior: contain;
}

#monitor .chat-message {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

#monitor .chat-message small {
  display: block;
  margin: 0;
  color: rgba(226, 232, 240, 0.72);
  font-weight: 700;
  line-height: 1.2;
}

#monitor .chat-message p {
  margin: 0;
  color: #f8fbff;
  line-height: 1.46;
  white-space: pre-wrap;
}

#monitor .chat-message.client {
  align-self: flex-start;
  background: #172638;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px 12px 12px 3px;
}

#monitor .chat-message.bot,
#monitor .chat-message.attendant {
  align-self: flex-end;
  background: #1f4f86;
  border: 1px solid rgba(125, 180, 255, 0.28);
  border-radius: 12px 12px 3px 12px;
}

#monitor .chat-message.system {
  align-self: center;
  max-width: min(76%, 560px);
  text-align: center;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
}

#monitor .message-media {
  min-width: 0;
}

#monitor .message-media audio {
  width: 100%;
  max-width: 340px;
}

#monitor .message-media-link,
#monitor .message-media img,
#monitor .message-media video {
  width: 100%;
  max-width: 360px;
}

#monitor .message-media img,
#monitor .message-media video {
  max-height: min(380px, 58vh);
}

@media (min-width: 701px) {
  #monitor .chat-message {
    padding: 10px 12px;
    font-size: 14px;
  }

  #monitor .chat-message small {
    font-size: 11px;
  }
}

@media (max-width: 700px) {
  #monitor .monitor-summary {
    gap: 5px;
  }

  #monitor .monitor-panel {
    min-height: calc(100dvh - 190px);
    height: calc(100dvh - 190px);
  }

  #monitor .conversation-sidebar {
    padding: 9px;
  }

  #monitor .conversation-item {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 8px;
    min-height: 58px;
    padding: 7px 5px;
  }

  #monitor .conversation-item .conversation-avatar {
    width: 36px;
    height: 36px;
  }

  #monitor .conversation-name strong {
    font-size: 13px;
    line-height: 1.18;
  }

  #monitor .conversation-name small {
    font-size: 9px;
  }

  #monitor .conversation-phone,
  #monitor .conversation-preview {
    font-size: 11px;
    line-height: 1.25;
  }

  #monitor .conversation-preview {
    max-width: 100%;
  }

  #monitor .monitor-panel.chat-open,
  #monitor .monitor-panel.chat-open #chat-content {
    min-height: calc(100dvh - 108px);
    height: calc(100dvh - 108px);
  }

  #monitor .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto 32px minmax(0, 1fr);
    gap: 6px;
    padding: 7px;
  }

  #monitor .chat-back {
    min-width: 52px;
  }

  #monitor .chat-client-block strong {
    font-size: 13px;
    line-height: 1.15;
  }

  #monitor .chat-client-block small {
    font-size: 10px;
    line-height: 1.1;
  }

  #monitor .monitor-panel.chat-open .chat-actions {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  #monitor .monitor-panel.chat-open .chat-actions::-webkit-scrollbar {
    display: none;
  }

  #monitor .monitor-panel.chat-open .chat-actions .badge,
  #monitor .monitor-panel.chat-open .chat-actions .btn {
    flex: 0 0 auto;
    min-width: fit-content;
    max-width: none;
    white-space: nowrap;
  }

  #monitor .chat-messages {
    padding: 8px;
    gap: 8px;
  }

  #monitor .chat-message,
  #monitor .monitor-panel.chat-open .chat-message {
    max-width: 86%;
    padding: 8px 9px;
    font-size: 13px;
  }

  #monitor .chat-message small {
    font-size: 9px;
  }

  #monitor .chat-message p {
    line-height: 1.38;
  }

  #monitor .chat-message.system {
    max-width: 92%;
  }

  #monitor .chat-compose {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #monitor .chat-compose textarea {
    font-size: 14px;
    line-height: 1.3;
  }
}

/* Chat roomier: keep the conversation itself as the main reading area. */
#monitor .monitor-panel {
  height: clamp(640px, calc(100dvh - 260px), 860px);
  min-height: 640px;
}

#monitor .monitor-panel.chat-open {
  grid-template-columns: minmax(0, 1fr);
  height: clamp(680px, calc(100dvh - 220px), 900px);
  min-height: 680px;
}

#monitor .monitor-panel.chat-open #chat-content {
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  height: 100%;
}

#monitor .monitor-panel.chat-open .chat-header {
  grid-template-columns: auto 40px minmax(180px, 1fr) auto;
  gap: 10px;
  padding: 10px 14px;
}

#monitor .monitor-panel.chat-open .chat-profile-button {
  grid-column: 2;
  grid-row: 1;
}

#monitor .monitor-panel.chat-open .chat-client-block {
  grid-column: 3;
  grid-row: 1;
}

#monitor .monitor-panel.chat-open .attendant-field {
  display: none;
}

#monitor .monitor-panel.chat-open .chat-actions {
  grid-column: 4;
  grid-row: 1;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  overflow-x: auto;
  max-width: 48vw;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

#monitor .monitor-panel.chat-open .chat-actions .badge,
#monitor .monitor-panel.chat-open .chat-actions .btn {
  flex: 0 0 auto;
  min-height: 32px;
  padding-inline: 10px;
  font-size: 12px;
  white-space: nowrap;
}

#monitor .monitor-panel.chat-open .chat-messages {
  padding: 18px 24px;
}

#monitor .monitor-panel.chat-open .chat-message {
  max-width: min(76%, 820px);
  font-size: 15px;
}

#monitor .monitor-panel.chat-open .chat-compose-tools {
  display: none;
}

#monitor .monitor-panel.chat-open .chat-hint {
  display: none;
}

#monitor .monitor-panel.chat-open .chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px 14px;
}

#monitor .monitor-panel.chat-open .chat-compose textarea {
  min-height: 48px;
  max-height: 120px;
}

@media (max-width: 1180px) {
  #monitor .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto 38px minmax(0, 1fr);
  }

  #monitor .monitor-panel.chat-open .chat-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  #monitor .monitor-summary {
    margin-bottom: 6px;
  }

  #monitor .kpi {
    min-height: 64px;
    padding: 7px 8px;
  }

  #monitor .kpi strong {
    margin-top: 4px;
    font-size: 20px;
  }

  #monitor .monitor-panel,
  #monitor .monitor-panel.chat-open,
  #monitor .monitor-panel.chat-open #chat-content {
    height: calc(100dvh - 96px);
    min-height: calc(100dvh - 96px);
  }

  #monitor .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto 34px minmax(0, 1fr);
    gap: 7px;
    padding: 7px 8px 5px;
  }

  #monitor .monitor-panel.chat-open .chat-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 5px;
    align-items: center;
    flex-direction: row !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: none;
    padding-bottom: 1px;
    scrollbar-width: none;
  }

  #monitor .monitor-panel.chat-open .chat-actions::-webkit-scrollbar {
    display: none;
  }

  #monitor .monitor-panel.chat-open .chat-actions .badge,
  #monitor .monitor-panel.chat-open .chat-actions .btn {
    width: auto !important;
    flex: 0 0 auto;
    min-width: max-content;
    min-height: 29px;
    padding: 0 9px;
    border-radius: 7px;
    font-size: 11px;
    white-space: nowrap;
  }

  #monitor .monitor-panel.chat-open .chat-messages {
    padding: 10px 8px;
    gap: 9px;
  }

  #monitor .monitor-panel.chat-open .chat-message {
    max-width: 92%;
    padding: 9px 10px;
    font-size: 14px;
  }

  #monitor .monitor-panel.chat-open .chat-message p {
    line-height: 1.42;
  }

  #monitor .monitor-panel.chat-open .chat-compose {
    gap: 7px;
    padding: 7px 8px calc(8px + env(safe-area-inset-bottom));
  }

  #monitor .monitor-panel.chat-open .chat-compose textarea {
    min-height: 46px;
    max-height: 92px;
  }

  #monitor .monitor-panel.chat-open .chat-compose .btn {
    min-width: 72px;
    min-height: 46px;
  }
}

/* Mobile chat: final hardening for a clean operator app view. */
#monitor .chat-message,
#monitor .chat-message p,
#monitor .chat-message small,
#monitor .message-media span {
  text-align: left !important;
  word-spacing: normal !important;
  letter-spacing: 0 !important;
  text-wrap: auto !important;
  font-kerning: normal;
}

#monitor .chat-message p {
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

#monitor .chat-text {
  display: block;
  white-space: normal !important;
  text-align: left !important;
  text-align-last: left !important;
  text-justify: auto !important;
  word-spacing: normal !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

#monitor .chat-line {
  display: block;
  width: 100%;
  margin: 0;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: left;
  text-align-last: left;
  word-spacing: normal !important;
}

#monitor .chat-line.empty {
  height: 0.72em;
}

@media (max-width: 700px) {
  body.monitor-tab-active .hero {
    display: none;
  }

  body.monitor-tab-active .shell {
    padding-top: 8px;
  }

  body.monitor-tab-active .mobile-tab-select {
    margin-bottom: 8px;
  }

  #monitor.active {
    margin-top: 10px;
  }

  #monitor .monitor-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #monitor .kpi {
    min-height: 72px;
    padding: 10px;
  }

  #monitor .kpi small {
    font-size: 11px;
    line-height: 1.25;
  }

  #monitor .kpi strong {
    font-size: 24px;
  }

  #monitor .monitor-panel,
  #monitor .monitor-panel.chat-open,
  #monitor .monitor-panel.chat-open #chat-content {
    width: 100%;
    height: calc(100dvh - 74px);
    min-height: calc(100dvh - 74px);
    max-height: calc(100dvh - 74px);
    overflow: hidden;
  }

  #monitor .monitor-panel.chat-open .chat-header {
    grid-template-columns: auto 34px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  #monitor .monitor-panel.chat-open .chat-client-block {
    min-width: 0;
  }

  #monitor .monitor-panel.chat-open .chat-actions {
    width: 100%;
    min-width: 0;
    min-height: 31px;
  }

  #monitor .monitor-panel.chat-open .chat-actions .badge,
  #monitor .monitor-panel.chat-open .chat-actions .btn {
    min-height: 30px;
    padding-inline: 10px;
    font-size: 12px;
  }

  #monitor .monitor-panel.chat-open .chat-messages {
    padding: 12px 10px;
    gap: 10px;
  }

  #monitor .monitor-panel.chat-open .chat-message {
    width: auto;
    min-width: 0;
    max-width: 88%;
    padding: 10px 11px;
    border-radius: 11px;
    font-size: 14px;
  }

  #monitor .monitor-panel.chat-open .chat-message.attendant,
  #monitor .monitor-panel.chat-open .chat-message.bot {
    max-width: 88%;
  }

  #monitor .monitor-panel.chat-open .chat-message p {
    max-width: 100%;
    line-height: 1.48;
  }

  #monitor .monitor-panel.chat-open .chat-text {
    font-size: 14px;
    line-height: 1.48;
  }

  #monitor .monitor-panel.chat-open .chat-message small {
    font-size: 10px;
  }

  #monitor .monitor-panel.chat-open .chat-compose {
    align-items: stretch;
    padding: 8px 9px calc(9px + env(safe-area-inset-bottom));
  }

  #monitor .monitor-panel.chat-open .chat-compose textarea {
    min-height: 48px;
    font-size: 15px;
    line-height: 1.35;
  }
}

/* Monitor layout: desktop like WhatsApp Web, iPhone focused on the list until a chat is opened. */
@media (min-width: 701px) {
  #monitor .monitor-panel,
  #monitor .monitor-panel.chat-open {
    display: grid;
    grid-template-columns: clamp(300px, 34%, 390px) minmax(0, 1fr);
    height: min(78vh, 820px);
    min-height: 620px;
  }

  #monitor .monitor-panel.chat-open .conversation-sidebar {
    display: flex;
    flex-direction: column;
  }

  #monitor .monitor-panel.chat-open .chat-back {
    display: none;
  }

  #monitor .monitor-panel.chat-open .chat-header {
    grid-template-columns: 40px minmax(0, 1fr) minmax(150px, 230px) auto;
  }

  #monitor .monitor-panel.chat-open .chat-avatar {
    grid-column: 1;
  }

  #monitor .monitor-panel.chat-open .chat-client-block {
    grid-column: 2;
  }

  #monitor .monitor-panel.chat-open .attendant-field {
    grid-column: 3;
  }

  #monitor .monitor-panel.chat-open .chat-actions {
    grid-column: 4;
  }

  #monitor .chat-empty {
    min-height: 100%;
  }
}

@media (max-width: 700px) {
  #monitor .monitor-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    height: calc(100dvh - 82px);
    min-height: calc(100dvh - 82px);
    max-height: calc(100dvh - 82px);
  }

  #monitor .monitor-panel:not(.chat-open) {
    overflow: hidden;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-sidebar {
    display: flex;
    min-height: 0;
    padding: 12px;
  }

  #monitor .monitor-panel:not(.chat-open) .chat-panel,
  #monitor .monitor-panel:not(.chat-open) .chat-empty {
    display: none !important;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-list {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-item {
    min-height: 64px;
    padding-block: 8px;
  }

  #monitor .monitor-panel.chat-open {
    grid-template-columns: minmax(0, 1fr);
  }

  #monitor .monitor-panel.chat-open .conversation-sidebar {
    display: none;
  }
}

/* Monitor layout hard reset: clean desktop split and stable iPhone list. */
#monitor .conversation-sidebar {
  box-sizing: border-box;
  min-width: 0;
}

#monitor .conversation-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  overflow: visible;
}

#monitor .conversation-filters button {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#monitor .conversation-item {
  box-sizing: border-box;
  align-items: center;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

#monitor .conversation-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}

#monitor .conversation-meta {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
  overflow: hidden;
}

#monitor .conversation-status {
  min-height: 20px;
  max-width: 64px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 20px;
  color: #102015;
  background: #ffd166;
  overflow: hidden;
  text-overflow: ellipsis;
}

#monitor .conversation-item.active .conversation-status {
  background: #7ee2a8;
}

#monitor .conversation-name {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

#monitor .conversation-name small {
  white-space: nowrap;
}

@media (min-width: 701px) {
  #monitor .monitor-panel,
  #monitor .monitor-panel.chat-open {
    grid-template-columns: clamp(250px, 28vw, 320px) minmax(520px, 1fr);
    height: min(82vh, 860px);
    min-height: 640px;
  }

  #monitor .monitor-panel.chat-open #chat-content {
    display: grid;
    height: 100%;
  }

  #monitor .monitor-panel.chat-open .chat-message {
    max-width: min(76%, 720px);
  }

  #monitor .conversation-item {
    grid-template-columns: 42px minmax(0, 1fr);
    min-height: 74px;
    gap: 10px;
    padding: 9px 8px;
  }

  #monitor .conversation-item .conversation-avatar {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 700px) {
  #monitor .monitor-panel,
  #monitor .monitor-panel:not(.chat-open) {
    display: block;
    height: calc(100dvh - 82px);
    min-height: calc(100dvh - 82px);
    max-height: calc(100dvh - 82px);
    overflow: hidden;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-sidebar {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    width: 100%;
    height: 100%;
    padding: 12px 14px;
    border-right: 0;
  }

  #monitor .monitor-panel:not(.chat-open) .panel-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
  }

  #monitor .monitor-panel:not(.chat-open) .panel-title > div {
    min-width: 0;
  }

  #monitor .monitor-panel:not(.chat-open) .panel-title span,
  #monitor .monitor-panel:not(.chat-open) .panel-title h2 {
    min-width: 0;
  }

  #monitor .monitor-panel:not(.chat-open) .panel-title .label {
    display: block;
    margin: 0 0 2px;
    font-size: 10px;
    line-height: 1.1;
  }

  #monitor .monitor-panel:not(.chat-open) .panel-title h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.1;
    white-space: nowrap;
  }

  #monitor .monitor-panel:not(.chat-open) #monitor-refresh {
    min-width: 88px;
    min-height: 40px;
    padding: 0 12px;
    font-size: 12px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-sidebar > input {
    width: 100%;
    height: 44px;
    margin: 0 0 10px;
    font-size: 16px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 8px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-filters button {
    min-height: 34px;
    padding: 0 5px;
    font-size: 11px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-list {
    display: grid;
    align-content: start;
    gap: 0;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 2px calc(18px + env(safe-area-inset-bottom)) 0;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-item {
    grid-template-columns: 44px minmax(0, 1fr);
    min-height: 76px;
    gap: 10px;
    padding: 9px 4px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-item .conversation-avatar {
    width: 44px;
    height: 44px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-name strong {
    font-size: 14px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-preview,
  #monitor .monitor-panel:not(.chat-open) .conversation-phone {
    font-size: 11px;
  }

  #monitor .monitor-panel:not(.chat-open) .conversation-status {
    max-width: 56px;
  }

  #monitor .monitor-panel.chat-open {
    display: grid;
  }
}

/* Final mobile chat readability guard. */
@media (max-width: 700px) {
  #monitor .monitor-panel.chat-open .chat-messages {
    align-items: stretch !important;
    padding: 12px 10px !important;
  }

  #monitor .monitor-panel.chat-open .chat-message {
    display: block !important;
    width: auto !important;
    min-width: min(260px, calc(100vw - 48px)) !important;
    max-width: calc(100vw - 42px) !important;
    box-sizing: border-box;
    flex: 0 1 auto !important;
    transform: none !important;
  }

  #monitor .monitor-panel.chat-open .chat-message.client {
    margin-right: auto !important;
  }

  #monitor .monitor-panel.chat-open .chat-message.bot,
  #monitor .monitor-panel.chat-open .chat-message.attendant {
    margin-left: auto !important;
  }

  #monitor .monitor-panel.chat-open .chat-text,
  #monitor .monitor-panel.chat-open .chat-line,
  #monitor .monitor-panel.chat-open .chat-message p {
    display: block;
    width: auto;
    min-width: 0;
    max-width: 100%;
    white-space: pre-wrap !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    line-height: 1.45 !important;
    font-size: 14px !important;
    letter-spacing: 0 !important;
    word-spacing: normal !important;
  }

  #monitor .monitor-panel.chat-open .chat-message small {
    white-space: normal;
    overflow-wrap: break-word;
  }
}

/* iPhone monitor parity: keep chat text readable like desktop. */
@media (max-width: 700px) {
  #monitor.active .monitor-panel.chat-open,
  #monitor.active .monitor-panel.chat-open #chat-content {
    width: 100% !important;
    min-width: 0 !important;
  }

  #monitor.active .monitor-panel.chat-open .chat-message,
  #monitor.active .monitor-panel.chat-open .chat-message.client,
  #monitor.active .monitor-panel.chat-open .chat-message.bot,
  #monitor.active .monitor-panel.chat-open .chat-message.attendant {
    width: auto !important;
    min-width: min(270px, calc(100vw - 44px)) !important;
    max-width: calc(100vw - 40px) !important;
  }

  #monitor.active .monitor-panel.chat-open .chat-message p,
  #monitor.active .monitor-panel.chat-open .chat-text,
  #monitor.active .monitor-panel.chat-open .chat-line {
    display: block !important;
    white-space: pre-wrap !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    line-break: auto !important;
    text-align: left !important;
  }
}

/* Mobile monitor final reset: prevents iPhone from squeezing text into columns. */
@media (max-width: 700px) {
  body.monitor-tab-active {
    overflow-x: hidden !important;
  }

  body.monitor-tab-active .shell,
  body.monitor-tab-active .tab-content,
  #monitor.active,
  #monitor.active * {
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #monitor.active {
    width: 100% !important;
    overflow-x: hidden !important;
  }

  #monitor.active .monitor-panel,
  #monitor.active .monitor-panel:not(.chat-open),
  #monitor.active .monitor-panel.chat-open {
    display: block !important;
    width: 100% !important;
    height: calc(100dvh - 86px) !important;
    min-height: calc(100dvh - 86px) !important;
    max-height: calc(100dvh - 86px) !important;
    overflow: hidden !important;
  }

  #monitor.active .monitor-panel:not(.chat-open) .conversation-sidebar {
    display: grid !important;
    grid-template-rows: auto auto auto minmax(0, 1fr) !important;
    width: 100% !important;
    height: 100% !important;
    padding: 12px !important;
    overflow: hidden !important;
  }

  #monitor.active .monitor-panel:not(.chat-open) #chat-content,
  #monitor.active .monitor-panel:not(.chat-open) .chat-panel,
  #monitor.active .monitor-panel:not(.chat-open) .chat-empty {
    display: none !important;
  }

  #monitor.active .monitor-panel.chat-open .conversation-sidebar,
  #monitor.active .monitor-panel.chat-open .chat-empty {
    display: none !important;
  }

  #monitor.active .monitor-panel.chat-open #chat-content {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
  }

  #monitor.active .conversation-list {
    display: grid !important;
    align-content: start !important;
    gap: 0 !important;
    width: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  #monitor.active .conversation-item {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) !important;
    width: 100% !important;
    min-height: 74px !important;
    padding: 9px 4px !important;
    gap: 10px !important;
  }

  #monitor.active .conversation-name,
  #monitor.active .conversation-copy,
  #monitor.active .conversation-preview,
  #monitor.active .conversation-phone {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-align: left !important;
  }

  #monitor.active .conversation-status {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 112px !important;
    height: 22px !important;
    padding: 0 9px !important;
    font-size: 10px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  #monitor.active .chat-header {
    display: grid !important;
    grid-template-columns: auto 38px minmax(0, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 8px !important;
    overflow: hidden !important;
  }

  #monitor.active .chat-actions {
    grid-column: 1 / -1 !important;
    display: flex !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 7px !important;
    padding-bottom: 2px !important;
  }

  #monitor.active .chat-actions .btn,
  #monitor.active .chat-actions .badge {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;
    max-width: none !important;
    white-space: nowrap !important;
  }

  #monitor.active .chat-messages {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 12px 10px !important;
    gap: 9px !important;
  }

  #monitor.active .chat-message,
  #monitor.active .chat-message.client,
  #monitor.active .chat-message.bot,
  #monitor.active .chat-message.attendant,
  #monitor.active .chat-message.system {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 88% !important;
    padding: 9px 11px !important;
    font-size: 14px !important;
    line-height: 1.42 !important;
    overflow: visible !important;
    transform: none !important;
  }

  #monitor.active .chat-message.client {
    align-self: flex-start !important;
    margin-right: auto !important;
  }

  #monitor.active .chat-message.bot,
  #monitor.active .chat-message.attendant {
    align-self: flex-end !important;
    margin-left: auto !important;
  }

  #monitor.active .chat-message.system {
    align-self: center !important;
    max-width: 94% !important;
  }

  #monitor.active .chat-text,
  #monitor.active .chat-line,
  #monitor.active .chat-message p,
  #monitor.active .chat-message small {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    line-break: auto !important;
    hyphens: none !important;
    text-align: left !important;
    text-align-last: left !important;
    letter-spacing: 0 !important;
    word-spacing: normal !important;
  }

  #monitor.active .chat-text {
    font-size: 14px !important;
    line-height: 1.43 !important;
  }

  #monitor.active .chat-line.empty {
    height: 0.65em !important;
  }
}

/* Ajuste pontual: monitoramento com conversa aberta sem sobrepor avatar/nome. */
@media (min-width: 701px) {
  #monitor .monitor-panel.chat-open .chat-header {
    display: grid;
    grid-template-columns: auto 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 74px;
    padding: 12px 14px;
    overflow: visible;
  }

  #monitor .monitor-panel.chat-open .chat-back {
    grid-column: 1;
    grid-row: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    white-space: nowrap;
  }

  #monitor .monitor-panel.chat-open .chat-profile-button {
    grid-column: 2;
    grid-row: 1;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    display: grid;
    place-items: center;
    overflow: hidden;
  }

  #monitor .monitor-panel.chat-open .chat-avatar {
    width: 46px;
    height: 46px;
  }

  #monitor .monitor-panel.chat-open .chat-client-block {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
  }

  #monitor .monitor-panel.chat-open .attendant-field {
    display: none;
  }

  #monitor .monitor-panel.chat-open .chat-actions {
    grid-column: 4;
    grid-row: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    max-width: min(500px, 52vw);
    overflow: visible;
    padding: 0;
  }

  #monitor .monitor-panel.chat-open .chat-actions .btn,
  #monitor .monitor-panel.chat-open .chat-actions .badge {
    min-height: 34px;
    padding-inline: 10px;
    white-space: nowrap;
  }
}

.order-note.scheduled-note {
  color: #3b2700;
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.96), rgba(255, 159, 28, 0.88));
  border: 1px solid rgba(255, 209, 102, 0.88);
  font-weight: 850;
}

/* Assumir: left click edits attendant name, right click starts the support. */
#monitor .chat-actions .attendant-field {
  display: none !important;
  flex: 0 0 190px;
  width: 190px;
  max-width: min(210px, 45vw);
  margin: 0;
}

#monitor .chat-actions .attendant-field span {
  display: none;
}

#monitor .chat-actions .attendant-field input {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding-inline: 10px;
}

#monitor .monitor-panel.chat-open.attendant-name-open .chat-actions .attendant-field {
  display: grid !important;
  grid-column: auto !important;
  grid-row: auto !important;
}

#monitor .monitor-panel.chat-open.attendant-name-open .chat-actions {
  overflow: visible;
}

#monitor .monitor-panel.chat-open.attendant-name-open #chat-start {
  box-shadow: 0 0 0 2px rgba(32, 201, 151, 0.25);
}

@media (max-width: 700px) {
  #monitor.active .chat-actions .attendant-field {
    flex-basis: 170px !important;
    width: 170px !important;
    max-width: 72vw !important;
  }

  #monitor.active .monitor-panel.chat-open.attendant-name-open .chat-actions .attendant-field {
    display: grid !important;
  }
}
