@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Authentic WhatsApp Web Desktop Dark + Enterprise Pro Tokens */
  --app-bg: #0c1317;
  --rail-bg: #202c33;
  --sidebar-bg: #111b21;
  --header-bg: #202c33;
  --surface: #111b21;
  --surface-2: #202c33;
  --surface-3: #2a3942;
  --row-hover: #202c33;
  --row-active: #2a3942;
  --border: rgba(134, 150, 160, 0.16);
  --border-strong: rgba(134, 150, 160, 0.28);

  --text: #e9edef;
  --text-secondary: #8696a0;
  --text-muted: #667781;

  --wa-green: #00a884;
  --wa-green-hover: #06cf9c;
  --wa-green-soft: rgba(0, 168, 132, 0.16);
  --blue: #53bdeb;
  --blue-btn: #0284c7;
  --amber: #f59e0b;
  --danger: #ef4444;

  --chat-bg: #0b141a;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --bubble-text-in: #e9edef;
  --bubble-text-out: #e9edef;
  --bubble-meta: rgba(233, 237, 239, 0.62);
  --bubble-note-bg: #2b2312;
  --bubble-note-border: rgba(245, 158, 11, 0.45);
  --bubble-note-text: #fde68a;

  --input-bg: #2a3942;
  --page-bg: #0b141a;
  --card-bg: #111b21;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
}

body.light-theme {
  --app-bg: #eae6df;
  --rail-bg: #f0f2f5;
  --sidebar-bg: #ffffff;
  --header-bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e9edef;
  --row-hover: #f5f6f6;
  --row-active: #f0f2f5;
  --border: #e9edef;
  --border-strong: #d1d7db;

  --text: #111b21;
  --text-secondary: #54656f;
  --text-muted: #667781;

  --wa-green: #00a884;
  --wa-green-hover: #008f6f;
  --wa-green-soft: #d9fdd3;
  --blue: #53bdeb;
  --blue-btn: #0284c7;

  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-text-in: #111b21;
  --bubble-text-out: #111b21;
  --bubble-meta: #667781;
  --bubble-note-bg: #fef9c3;
  --bubble-note-border: #facc15;
  --bubble-note-text: #713f12;

  --input-bg: #ffffff;
  --page-bg: #f4f6f8;
  --card-bg: #ffffff;
  --shadow-sm: 0 1px 1.5px rgba(11, 20, 26, 0.12);
  --shadow-lg: 0 18px 48px rgba(11, 20, 26, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background: var(--app-bg);
  color: var(--text);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(134, 150, 160, 0.28); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(134, 150, 160, 0.48); }

button {
  cursor: pointer;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}
button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

input, select, textarea {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder {
  color: var(--text-secondary);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.16);
}

svg.ic {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}
svg.ic-sm { width: 16px; height: 16px; }
svg.ic-xs { width: 14px; height: 14px; }

/* ---------- BUTTON SYSTEM ---------- */
.btn {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--surface-3);
}
.btn-primary {
  background: var(--wa-green);
  color: #ffffff;
  border-color: var(--wa-green);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--wa-green-hover);
  border-color: var(--wa-green-hover);
}
.btn-blue {
  background: var(--blue-btn);
  color: #ffffff;
  border-color: var(--blue-btn);
}
.btn-blue:hover:not(:disabled) {
  filter: brightness(1.1);
}
.btn-gold {
  background: rgba(245, 158, 11, 0.16);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.32);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.22);
}
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; border-radius: 6px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.icon-btn:hover:not(:disabled) {
  background: rgba(134, 150, 160, 0.14);
  color: var(--text);
}
.icon-btn.active {
  background: var(--wa-green-soft);
  color: var(--wa-green);
}

/* ---------- LOGIN / AUTH SCREEN ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #00a884 0%, #00a884 210px, #111b21 210px, #0b141a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.login-card {
  width: 440px;
  max-width: 100%;
  background: #111b21;
  color: #e9edef;
  border: 1px solid rgba(134, 150, 160, 0.22);
  border-radius: 14px;
  padding: 34px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.login-brand h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.login-card .sub {
  color: #8696a0;
  font-size: 13.5px;
  margin-bottom: 22px;
}
.login-card input, .login-card select {
  background: #202c33;
  color: #e9edef;
  border-color: rgba(134, 150, 160, 0.28);
}
.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #202c33;
  padding: 4px;
  border-radius: 9px;
  margin-bottom: 18px;
}
.auth-switch button {
  padding: 8px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #8696a0;
}
.auth-switch button.active {
  background: #2a3942;
  color: #ffffff;
}
.field {
  margin-bottom: 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field input:not([type="checkbox"]):not([type="color"]),
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
}
.field label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quick-logins {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(134, 150, 160, 0.15);
}
.quick-logins span {
  width: 100%;
  font-size: 11px;
  color: #8696a0;
  margin-bottom: 2px;
}
.quick-logins button {
  font-size: 11.5px;
  padding: 4px 10px;
  background: #202c33;
  border: 1px solid rgba(134, 150, 160, 0.2);
  border-radius: 99px;
  color: #cbd5e1;
}
.quick-logins button:hover {
  background: #2a3942;
  color: #fff;
}

/* ---------- MAIN APP SHELL & WHATSAPP WEB RAIL ---------- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: var(--surface);
}
.rail {
  width: 64px;
  background: var(--rail-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 6px;
  flex-shrink: 0;
  z-index: 20;
}
.brand-dot {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--wa-green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #ffffff;
  margin-bottom: 8px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 168, 132, 0.28);
}
.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.rail-btn:hover {
  background: rgba(134, 150, 160, 0.14);
  color: var(--text);
}
.rail-btn.active {
  background: rgba(134, 150, 160, 0.22);
  color: var(--wa-green);
}
.rail-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--wa-green);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--rail-bg);
}
.rail-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--wa-green);
  border: 2px solid var(--rail-bg);
}
.rail-spacer { flex: 1; }
.rail-divider {
  width: 28px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.rail-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--wa-green);
}

/* ---------- VIEWS ---------- */
.view {
  flex: 1;
  display: none;
  height: 100vh;
  overflow: hidden;
  min-width: 0;
}
.view.active {
  display: flex;
}

/* ---------- AVATARS ---------- */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  background: #3b4a54;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-header { width: 40px; height: 40px; font-size: 14px; }
.avatar-sm { width: 36px; height: 36px; font-size: 13px; }
.avatar-xl { width: 78px; height: 78px; font-size: 24px; margin: 0 auto; }

/* ---------- WHATSAPP WEB CONVERSATION LIST (LEFT COLUMN) ---------- */
.ticket-col {
  width: 390px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.wa-list-header {
  height: 60px;
  padding: 0 12px;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
}
.wa-list-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.wa-list-title h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.25px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conn-live-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  cursor: pointer;
  background: var(--wa-green-soft);
  color: var(--wa-green);
  white-space: nowrap;
}
body.light-theme .conn-live-pill {
  color: #008069;
}
.conn-live-pill.warn {
  background: rgba(245, 158, 11, 0.16);
  color: var(--amber);
}

.wa-search-area {
  padding: 4px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.wa-search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0 12px;
  height: 36px;
}
.wa-search-box svg {
  color: var(--text-secondary);
}
.wa-search-box input {
  flex: 1;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0;
  font-size: 13.5px;
  height: 100%;
}

.wa-subfilters {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wa-subfilters select {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--surface-2);
  border-color: transparent;
}

/* Authentic WhatsApp Web Filter Chips */
.wa-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.wa-chip {
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.wa-chip:hover {
  background: var(--surface-3);
  color: var(--text);
}
.wa-chip.active {
  background: var(--wa-green-soft);
  color: var(--wa-green);
  font-weight: 600;
}
body.light-theme .wa-chip.active {
  color: #008069;
}
.chip-count {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.9;
}
.chip-count.pending-alert {
  background: var(--amber);
  color: #111b21;
  padding: 0 5px;
  border-radius: 99px;
}

/* WhatsApp Web Conversation Rows */
.ticket-list {
  flex: 1;
  overflow-y: auto;
}
.ticket-item {
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 13px;
  position: relative;
  transition: background 0.1s ease;
}
.ticket-item::after {
  content: "";
  position: absolute;
  right: 0;
  left: 75px;
  bottom: 0;
  height: 1px;
  background: var(--border);
}
.ticket-item:hover {
  background: var(--row-hover);
}
.ticket-item.selected {
  background: var(--row-active);
}
.ti-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ti-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.ti-name {
  font-weight: 500;
  font-size: 15.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticket-item.has-unread .ti-name {
  font-weight: 700;
}
.ti-time {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.ticket-item.has-unread .ti-time {
  color: var(--wa-green);
  font-weight: 600;
}
.ti-row2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ti-preview {
  font-size: 13.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.ti-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.conn-tag {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.agent-tag {
  font-size: 10.5px;
  color: var(--text-secondary);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
}
.unread-dot {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--wa-green);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- WHATSAPP WEB CENTER CHAT PANEL ---------- */
.chat-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--chat-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%238696a0' stroke-opacity='0.06' stroke-width='1.4'%3E%3Ccircle cx='24' cy='24' r='8'/%3E%3Cpath d='M78 18h18a4 4 0 0 1 4 4v12a4 4 0 0 1-4 4H84l-6 5v-5a4 4 0 0 1-4-4V22a4 4 0 0 1 4-4z'/%3E%3Cpath d='M20 78l8-12 10 14 6-8 8 10H20z'/%3E%3Crect x='74' y='74' width='22' height='16' rx='4'/%3E%3Ccircle cx='56' cy='54' r='4'/%3E%3C/g%3E%3C/svg%3E");
  position: relative;
  min-width: 0;
}

.chat-empty {
  flex: 1;
  background: var(--header-bg);
  border-bottom: 6px solid var(--wa-green);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  gap: 14px;
  padding: 32px;
  text-align: center;
}
.chat-empty-icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--wa-green-soft);
  color: var(--wa-green);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.chat-empty h3 {
  font-size: 26px;
  font-weight: 300;
  color: var(--text);
}
.chat-empty-lock {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-header {
  height: 60px;
  padding: 0 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  z-index: 5;
}
.ch-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
}
.ch-info {
  min-width: 0;
}
.ch-info h3 {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-info p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.ch-search-inp {
  width: 150px;
  height: 32px;
  font-size: 12.5px;
  padding: 0 10px;
  border-radius: 16px;
  background: var(--surface-3);
  border-color: transparent;
}

.presence-bar {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--wa-green);
  font-size: 12px;
  padding: 5px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.pinned-note-bar {
  background: var(--bubble-note-bg);
  border-bottom: 1px solid var(--bubble-note-border);
  color: var(--bubble-note-text);
  font-size: 12px;
  padding: 6px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.trial-top-banner {
  background: var(--surface-2);
  border-bottom: 1px solid var(--wa-green);
  padding: 6px 16px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ---------- AUTHENTIC WHATSAPP WEB MESSAGE BUBBLES ---------- */
.messages-box {
  flex: 1;
  overflow-y: auto;
  padding: 18px 6%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.date-divider {
  align-self: center;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 8px;
  margin: 10px 0;
  box-shadow: var(--shadow-sm);
}

.msg {
  max-width: 66%;
  padding: 6px 9px 7px 10px;
  border-radius: 8px;
  font-size: 14.2px;
  line-height: 1.42;
  word-break: break-word;
  position: relative;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2px;
}
.msg.in {
  align-self: flex-start;
  background: var(--bubble-in);
  color: var(--bubble-text-in);
  border-top-left-radius: 0;
}
.msg.in::before {
  content: "";
  position: absolute;
  top: 0;
  left: -7px;
  width: 0;
  height: 0;
  border-top: 0 solid transparent;
  border-right: 8px solid var(--bubble-in);
  border-bottom: 10px solid transparent;
}
.msg.out {
  align-self: flex-end;
  background: var(--bubble-out);
  color: var(--bubble-text-out);
  border-top-right-radius: 0;
}
.msg.out::before {
  content: "";
  position: absolute;
  top: 0;
  right: -7px;
  width: 0;
  height: 0;
  border-top: 0 solid transparent;
  border-left: 8px solid var(--bubble-out);
  border-bottom: 10px solid transparent;
}
.msg.note {
  align-self: center;
  width: 84%;
  max-width: 600px;
  background: var(--bubble-note-bg);
  border: 1px solid var(--bubble-note-border);
  color: var(--bubble-note-text);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 13px;
}
.msg.sys {
  align-self: center;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11.5px;
  padding: 4px 12px;
  border-radius: 7.5px;
  max-width: 88%;
  margin: 6px 0;
}
.msg-text {
  white-space: pre-wrap;
}
.msg-text a {
  color: var(--blue);
  text-decoration: underline;
}
body.light-theme .msg-text a {
  color: #027eb5;
}

.msg-quoted {
  background: rgba(0, 0, 0, 0.14);
  border-left: 4px solid var(--wa-green);
  border-radius: 5px;
  padding: 5px 9px;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.light-theme .msg-quoted {
  background: rgba(0, 0, 0, 0.05);
}

.msg-hover-tools {
  position: absolute;
  top: 4px;
  right: 6px;
  display: none;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 4px;
  box-shadow: var(--shadow-sm);
  z-index: 3;
}
.msg:hover .msg-hover-tools {
  display: flex;
}
.msg-hover-tools button {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}
.msg-hover-tools button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.msg-meta {
  font-size: 11px;
  color: var(--bubble-meta);
  margin-top: 2px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}
.ack-tick {
  display: inline-flex;
  align-items: center;
}
.ack-tick svg {
  width: 15px;
  height: 15px;
}
.ack-read {
  color: #53bdeb;
}
.msg-fail {
  margin-top: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.36);
  color: #fca5a5;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
body.light-theme .msg-fail {
  background: #fee2e2;
  color: #991b1b;
}

.msg img.media-img {
  max-width: 300px;
  max-height: 300px;
  border-radius: 6px;
  display: block;
  margin-bottom: 5px;
  cursor: zoom-in;
}
.audio-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 4px;
}
.audio-wrap audio {
  width: 235px;
  height: 36px;
}
.audio-speed-btn {
  background: rgba(134, 150, 160, 0.22);
  padding: 4px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
}
.msg-transcription {
  margin-top: 5px;
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.15);
  border-left: 3px solid var(--wa-green);
  font-size: 12.5px;
  line-height: 1.4;
}
body.light-theme .msg-transcription {
  background: rgba(0, 0, 0, 0.05);
}

/* ---------- WHATSAPP WEB COMPOSER BAR ---------- */
.composer-wrap {
  background: var(--header-bg);
  padding: 8px 14px;
  position: relative;
  border-top: 1px solid var(--border);
}
.composer-wrap.note-mode {
  background: var(--bubble-note-bg);
  border-top-color: var(--bubble-note-border);
}
.composer-bar-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-left: 4px solid var(--wa-green);
  border-radius: 7px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.composer-bar-preview img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
}
.recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 8px;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  display: inline-block;
  animation: pulseRec 1s infinite;
}
@keyframes pulseRec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.wa-composer-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.wa-composer-left {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-bottom: 3px;
}
.wa-composer-pill-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  background: rgba(134, 150, 160, 0.12);
}
.wa-composer-pill-btn:hover {
  background: rgba(134, 150, 160, 0.22);
  color: var(--text);
}
.wa-composer-pill-btn.ai {
  color: var(--wa-green);
  background: var(--wa-green-soft);
}
body.light-theme .wa-composer-pill-btn.ai {
  color: #008069;
}
.wa-composer-pill-btn.note-on {
  background: var(--amber);
  color: #111b21;
}

.wa-input-wrap {
  flex: 1;
  display: flex;
  background: var(--input-bg);
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
}
.wa-input-wrap:focus-within {
  border-color: rgba(0, 168, 132, 0.45);
}
.wa-input-wrap textarea {
  flex: 1;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0;
  resize: none;
  min-height: 22px;
  max-height: 130px;
  font-size: 14.5px;
  line-height: 1.4;
}

.wa-send-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--wa-green);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wa-send-circle:hover:not(:disabled) {
  background: var(--wa-green-hover);
}

.qr-popup {
  position: absolute;
  bottom: 100%;
  left: 14px;
  right: 14px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 30;
}
.qr-popup.open { display: block; }
.qr-opt {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.qr-opt:hover, .qr-opt.active {
  background: var(--row-hover);
}
.qr-opt .sc {
  color: var(--wa-green);
  font-weight: 700;
  font-size: 13px;
}
.qr-opt .tx {
  color: var(--text-secondary);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.emoji-popover {
  position: absolute;
  bottom: 100%;
  left: 14px;
  width: 308px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px;
  display: none;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}
.emoji-popover.open { display: grid; }
.emoji-popover button {
  font-size: 20px;
  padding: 4px;
  border-radius: 6px;
}
.emoji-popover button:hover {
  background: var(--row-hover);
}

.drop-overlay {
  position: absolute;
  inset: 14px;
  background: rgba(17, 27, 33, 0.9);
  border: 2px dashed var(--wa-green);
  border-radius: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--wa-green);
  z-index: 40;
  pointer-events: none;
}
.chat-col.dragging .drop-overlay { display: flex; }

/* ---------- COLLAPSIBLE RIGHT CONTACT DRAWER ---------- */
.panel-col {
  width: 320px;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.drawer-header {
  height: 60px;
  padding: 0 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}
.drawer-section {
  padding: 16px;
  border-bottom: 6px solid var(--app-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.drawer-section h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.safety-banner {
  background: var(--bubble-note-bg);
  border: 1px solid var(--bubble-note-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--bubble-note-text);
}

/* ---------- ENTERPRISE SAAS MANAGEMENT VIEWS ---------- */
.page-wrap {
  flex: 1;
  background: var(--page-bg);
  padding: 28px 34px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.page-head h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.card h4 {
  font-size: 14.5px;
  font-weight: 700;
}
.qr-box {
  background: #ffffff;
  padding: 12px;
  border-radius: 12px;
  align-self: center;
  border: 1px solid #e2e8f0;
}
.qr-box img {
  width: 220px;
  height: 220px;
  display: block;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table th, .table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.table th {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--row-hover); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
#kpiGrid {
  grid-template-columns: repeat(4, 1fr);
}
@media (max-width: 1150px) {
  #kpiGrid { grid-template-columns: repeat(2, 1fr); }
  .ticket-col { width: 340px; }
}
.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.kpi .val {
  font-size: 28px;
  font-weight: 800;
  color: var(--wa-green);
  margin-top: 6px;
  letter-spacing: -0.5px;
}
.kpi .lbl {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ---------- MODALS & LIGHTBOX ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 26, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  padding: 16px;
}
.modal-card {
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 26, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 180;
  padding: 24px;
}
.lightbox img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 84px;
  background: #202c33;
  border-left: 4px solid var(--wa-green);
  color: #e9edef;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  display: none;
  z-index: 250;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.hidden {
  display: none !important;
}

/* =====================================================================
   v5 — Reações, encaminhar, histórico, alertas de conexão, relatórios,
        configurações novas e layout para celular
   ===================================================================== */
.mobile-only { display: none !important; }

/* Banner de número desconectado */
.conn-alert-banner {
  background: rgba(239, 68, 68, 0.14);
  border-bottom: 1px solid rgba(239, 68, 68, 0.55);
  color: var(--text);
  padding: 8px 16px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 6;
}
.conn-alert-banner b { color: var(--danger); }
.conn-card-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
}

/* Carregar anteriores + divisores de atendimento antigo */
.load-older {
  align-self: center;
  margin: 4px 0 10px;
  font-size: 12px;
}
.ticket-divider {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 11.5px;
  margin: 12px 0 6px;
}
.ticket-divider::before,
.ticket-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}
.msg.from-old-ticket { opacity: 0.86; }

/* Reações */
.msg-reactions {
  position: absolute;
  bottom: -12px;
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 1px 6px;
  font-size: 13px;
  line-height: 18px;
  box-shadow: var(--shadow-sm);
  z-index: 2;
}
.msg.in .msg-reactions { left: 8px; }
.msg.out .msg-reactions { right: 8px; }
.msg.has-reaction { margin-bottom: 14px; }
.reaction-picker {
  position: fixed;
  z-index: 200;
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 4px 6px;
  box-shadow: var(--shadow-lg);
}
.reaction-picker button {
  font-size: 20px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
}
.reaction-picker button:hover,
.reaction-picker button.current { background: var(--surface-3); }
.reaction-picker .rp-remove { font-size: 12px; width: auto; padding: 0 8px; border-radius: 16px; color: var(--text-secondary); }
.msg-forwarded {
  font-size: 11.5px;
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Modal encaminhar */
.fwd-preview {
  background: var(--surface-2);
  border-left: 4px solid var(--wa-green);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
  max-height: 80px;
  overflow: hidden;
  white-space: pre-wrap;
}
.fwd-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.fwd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.fwd-item:hover { background: var(--row-hover); }
.fwd-item .fwd-sub { font-size: 11.5px; color: var(--text-secondary); }
.fwd-or {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Configurações */
.card-help { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.set-toggle { font-size: 13px; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.4; }
.set-toggle input { margin-top: 2px; }
.set-toggle small { color: var(--text-secondary); }
.radio-list { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
.schedule-grid { display: flex; flex-direction: column; gap: 6px; }
.schedule-row {
  display: grid;
  grid-template-columns: 130px 1fr 1fr;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.schedule-row input[type="time"] { padding: 6px 8px; }
.schedule-row.off input[type="time"] { opacity: 0.4; }

/* Relatórios */
.section-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: -8px; }
.report-filters { gap: 12px; }
.period-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.report-filter-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.report-filter-fields .field { min-width: 140px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }
.muted-note { font-weight: 400; color: var(--text-secondary); font-size: 12px; }
.table-scroll { width: 100%; overflow-x: auto; }
.bar-chart { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: 18px; }
.bar-col { flex: 1; min-width: 6px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bar-stack { width: 100%; display: flex; gap: 1px; align-items: flex-end; height: 100%; }
.bar { flex: 1; background: var(--wa-green); border-radius: 3px 3px 0 0; min-height: 1px; }
.bar.alt { background: var(--blue); }
.bar.peak { background: var(--amber); }
.bar-label { font-size: 9.5px; color: var(--text-muted); margin-top: 4px; white-space: nowrap; }
.bar-val { position: absolute; top: -2px; font-size: 9.5px; color: var(--text-secondary); }
.chart-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--text-secondary); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.csat-bars { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 12px; }
.csat-bar-row { display: grid; grid-template-columns: 70px 1fr 40px; gap: 8px; align-items: center; }
.csat-bar-track { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.csat-bar-fill { height: 100%; background: var(--wa-green); }

/* Toque (celular/tablet): ferramentas da mensagem aparecem ao tocar no balão */
@media (hover: none) {
  .msg:hover .msg-hover-tools { display: none; }
  .msg.tools-open .msg-hover-tools { display: flex; }
}

/* ---------- CELULAR / TELAS PEQUENAS ---------- */
@media (max-width: 820px) {
  .mobile-only { display: inline-flex !important; }
  body { height: 100dvh; }
  .app { flex-direction: column-reverse; height: 100dvh; }
  .view { height: auto; flex: 1; min-height: 0; }

  /* Barra de navegação vira barra inferior */
  .rail {
    width: 100%;
    height: 56px;
    flex-direction: row;
    padding: 0 6px;
    gap: 2px;
    border-right: none;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    justify-content: space-between;
  }
  .rail .brand-dot, .rail-spacer, .rail-divider, #btnShortcutsHelp, .rail-user-avatar { display: none; }
  .rail-btn { width: 40px; height: 40px; flex-shrink: 0; }

  /* Inbox: lista OU conversa */
  #view-inbox { position: relative; }
  .ticket-col { width: 100%; border-right: none; }
  .chat-col { display: none; width: 100%; }
  .panel-col { display: none; }
  body.mobile-chat-open .ticket-col { display: none; }
  body.mobile-chat-open .chat-col { display: flex; }
  body.mobile-chat-open.mobile-drawer-open .chat-col { display: none; }
  body.mobile-chat-open.mobile-drawer-open .panel-col { display: flex !important; width: 100%; }

  .chat-header { height: auto; min-height: 56px; flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .ch-left { flex: 1; min-width: 0; }
  .ch-actions { width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .ch-search-inp, #btnExportChat, #btnToggleDrawer { display: none; }
  .messages-box { padding: 12px 10px; }
  .msg { max-width: 86%; }
  .wa-composer-bar { gap: 4px; padding: 6px; }
  .wa-composer-pill-btn span { display: none; }
  .composer-bar-preview b, #attachName, #quoteBarText { max-width: 60vw !important; }

  /* Páginas de gestão */
  .page-wrap { padding: 16px 12px; gap: 14px; }
  .page-head h2 { font-size: 18px; }
  .page-head input { width: 100% !important; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  #kpiGrid, .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .kpi .val { font-size: 22px; }
  .report-grid { grid-template-columns: 1fr; }
  #view-settings .page-wrap > div[style*="grid"] { grid-template-columns: 1fr !important; }
  .grid-cards { grid-template-columns: 1fr; }
  .schedule-row { grid-template-columns: 100px 1fr 1fr; }
  .card div[style*="grid-template-columns:165px"] { grid-template-columns: 1fr !important; }
  .toast { left: 12px; right: 12px; bottom: 70px; }
  .modal-card { padding: 16px; }
}

/* v5 — ajustes de layout encontrados no teste visual */
/* Ferramentas da mensagem ficam acima do balão (não espremem em mensagens curtas) */
.msg-hover-tools { white-space: nowrap; top: -24px; right: 0; }
.msg.in .msg-hover-tools { right: auto; left: 0; }
.messages-box { padding-top: 30px; }
/* Cabeçalho da conversa: o nome do cliente não some quando há muitos botões */
.ch-left { flex: 1 1 auto; min-width: 150px; }
.ch-actions { flex-shrink: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.ch-actions::-webkit-scrollbar { display: none; }
.ch-actions > * { flex-shrink: 0; }
.wa-input-wrap { min-width: 0; }
@media (max-width: 1500px) {
  .ch-search-inp { width: 110px; }
}
@media (max-width: 820px) {
  #btnEmoji, #btnOpenQuick { display: none; }
  .wa-composer-left { gap: 0; }
  .wa-composer-pill-btn { padding: 6px; }
  .wa-input-wrap { padding: 8px 10px; }
  #btnRecord { width: 38px !important; height: 38px !important; }
  .wa-send-circle { flex-shrink: 0; }
}
.chat-col { min-height: 0; overflow: hidden; }
.chat-empty { min-height: 0; }
@media (max-width: 820px) {
  .ch-left { flex: 1 1 0; }
}
.backup-status { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-secondary); padding: 10px 12px; background: var(--surface-2); border-radius: 8px; }
/* v5.2 — IA, armazenamento, mídia expirada, motor */
.storage-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 820px) { .storage-grid { grid-template-columns: 1fr; } }
.media-expired {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, 0.14); border: 1px dashed var(--border-strong);
  padding: 8px 11px; border-radius: 6px; margin-bottom: 5px;
  font-size: 12.5px; color: var(--text-secondary);
}
.media-kept { font-size: 11px; color: var(--amber); margin-left: 6px; }
.engine-update {
  background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.5;
}
.usage-table { width: 100%; font-size: 12px; border-collapse: collapse; margin-top: 6px; }
.usage-table td, .usage-table th { padding: 5px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.usage-table th { color: var(--text-secondary); font-weight: 600; }
/* v5.3 — logs e avisos */
.lvl { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.lvl-critical { background: rgba(239, 68, 68, 0.18); color: var(--danger); }
.lvl-error { background: rgba(245, 158, 11, 0.16); color: var(--amber); }
.lvl-warning { background: var(--surface-3); color: var(--text-secondary); }
.err-code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--text); }
.err-msg { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.err-pre { background: var(--surface-2); border-radius: 8px; padding: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
#view-settings details { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
#view-settings details[open] { gap: 8px; }
#view-settings details > *:not(summary) { margin-top: 8px; }
