* {
  box-sizing: border-box;
}

:root {
  --bg: #07131b;
  --panel: #0d1f2b;
  --panel-2: #102b3a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef7fb;
  --muted: #9db4bf;
  --primary: #2086c2;
  --primary-2: #2aa7ee;
  --danger: #c93f4a;
  --success: #26c281;
  --meet: #7c4dff;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(32, 134, 194, 0.25), transparent 35%),
    radial-gradient(circle at bottom right, rgba(124, 77, 255, 0.18), transparent 35%),
    var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

button,
input {
  font: inherit;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  background: rgba(13, 31, 43, 0.92);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 28px;
  backdrop-filter: blur(16px);
}

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

.brand-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--meet));
  box-shadow: 0 12px 30px rgba(32, 134, 194, 0.25);
  font-size: 26px;
}

.brand-icon.small {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 25px;
}

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

.config-alert {
  margin: 0 0 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(201, 63, 74, 0.15);
  border: 1px solid rgba(201, 63, 74, 0.35);
  color: #ffd8dc;
  font-size: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 18px;
}

.tab {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 11px;
  cursor: pointer;
}

.tab.active {
  background: var(--primary);
  color: white;
}

.form {
  display: grid;
  gap: 10px;
}

.form label {
  color: var(--muted);
  font-size: 14px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
}

input:focus {
  border-color: rgba(42, 167, 238, 0.8);
  box-shadow: 0 0 0 4px rgba(42, 167, 238, 0.12);
}

input::placeholder {
  color: rgba(238, 247, 251, 0.45);
}

.btn {
  border: 0;
  border-radius: 14px;
  color: white;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  margin-top: 8px;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
}

.btn.danger {
  background: var(--danger);
}

.btn.meet {
  background: linear-gradient(135deg, var(--meet), #5e35b1);
  white-space: nowrap;
}

.auth-help {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(7, 19, 27, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.topbar-brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.layout {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  padding: 14px;
}

.sidebar,
.chat,
.meeting-panel {
  min-height: 0;
  background: rgba(13, 31, 43, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
}

.sidebar-header,
.chat-header,
.meeting-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h2,
.chat-header h2,
.meeting-header h2 {
  margin: 0;
  font-size: 18px;
}

.chat-header p,
.meeting-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  min-width: 28px;
  text-align: center;
  border-radius: 999px;
  background: rgba(32, 134, 194, 0.18);
  color: #b9e5f5;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 700;
}

.search {
  margin: 14px;
  width: calc(100% - 28px);
}

.users-list {
  padding: 0 10px 12px;
  overflow-y: auto;
}

.user-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.user-item:hover,
.user-item.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(135deg, var(--primary), var(--meet));
  font-weight: 800;
}

.user-info {
  min-width: 0;
  flex: 1;
}

.user-info strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #697982;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(38, 194, 129, 0.12);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 14px;
  font-size: 14px;
}

.chat {
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.messages {
  flex: 1;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.welcome {
  margin: auto;
  text-align: center;
  color: var(--muted);
}

.welcome h3 {
  color: var(--text);
  margin-bottom: 8px;
}

.message {
  max-width: min(70%, 680px);
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
}

.message.mine {
  align-self: flex-end;
  background: rgba(32, 134, 194, 0.22);
}

.message.system {
  align-self: center;
  max-width: 90%;
  background: rgba(124, 77, 255, 0.18);
  color: #e6ddff;
  text-align: center;
}

.message .name {
  display: block;
  color: #b9e5f5;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.message .text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.message .time {
  display: block;
  text-align: right;
  color: rgba(238, 247, 251, 0.55);
  font-size: 11px;
  margin-top: 5px;
}

.message-form {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.meeting-panel {
  display: flex;
  flex-direction: column;
}

.meeting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.meet-box {
  flex: 1;
  min-height: 440px;
  background: #000;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  z-index: 1000;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(16, 43, 58, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
}

@media (min-width: 1180px) {
  .layout.with-meeting {
    grid-template-columns: 300px minmax(360px, 1fr) minmax(420px, 0.9fr);
  }
}

@media (max-width: 980px) {
  .app {
    height: auto;
    min-height: 100vh;
  }

  .layout,
  .layout.with-meeting {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 340px;
  }

  .chat {
    min-height: 620px;
  }

  .meeting-panel {
    min-height: 620px;
  }
}

@media (max-width: 560px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1;
  }

  .layout {
    padding: 10px;
    gap: 10px;
  }

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

  .message {
    max-width: 92%;
  }

  .message-form {
    grid-template-columns: 1fr;
  }

  .btn.meet {
    width: 100%;
  }
}


/* =========================================================
   ETAPA 3.2 - ADMIN, SETORES E GRUPOS
   ========================================================= */

.btn.admin {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 16px 8px;
  color: #b9e5f5;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-section-title small {
  min-width: 24px;
  text-align: center;
  border-radius: 999px;
  padding: 3px 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.compact-list {
  flex: 0 0 auto;
  max-height: 38%;
}

.user-item.group .avatar {
  background: linear-gradient(135deg, #7c4dff, #2086c2);
}

.user-item.blocked {
  opacity: 0.52;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(12px);
}

.admin-modal {
  width: min(1180px, 100%);
  max-height: min(90vh, 880px);
  display: flex;
  flex-direction: column;
  background: rgba(13, 31, 43, 0.98);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 21px;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.admin-tab {
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.admin-tab.active {
  color: #fff;
  background: var(--primary);
}

.admin-panel {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}

.admin-grid.two {
  grid-template-columns: 360px 1fr;
}

.admin-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
}

.admin-card h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-card-header h3 {
  margin: 0;
}

.table-wrap {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

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

.admin-table th,
.admin-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: #b9e5f5;
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table .mini-btn,
.setor-item .mini-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.ok {
  color: #c9ffe5;
  background: rgba(38, 194, 129, 0.16);
}

.status-pill.no {
  color: #ffd8dc;
  background: rgba(201, 63, 74, 0.16);
}

.admin-form {
  display: grid;
  gap: 10px;
}

.admin-form label {
  color: var(--muted);
  font-size: 13px;
}

.admin-form select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
}

.admin-form select option {
  color: #111;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-actions .btn {
  flex: 1;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.soft-line {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

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

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

.setor-item strong {
  display: block;
}

.setor-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.sync-result {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.sync-result .sync-item {
  padding: 10px;
  border-radius: 14px;
  background: rgba(124, 77, 255, 0.14);
  border: 1px solid rgba(124, 77, 255, 0.22);
  font-size: 13px;
}

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

  .admin-modal {
    max-height: 94vh;
  }
}

@media (max-width: 560px) {
  .modal-overlay {
    padding: 8px;
  }

  .modal-header,
  .admin-tabs {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-panel {
    padding: 12px;
  }
}


/* =========================================================
   ETAPA 3.3 - LISTAGEM DE SETORES E GRUPOS
   ========================================================= */

.setor-item-detalhado {
  align-items: flex-start;
  gap: 12px;
}

.setor-meta {
  display: block;
  margin-top: 6px;
}

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

.status-pill.warn {
  color: #ffe7a3;
  background: rgba(255, 193, 7, 0.14);
  border: 1px solid rgba(255, 193, 7, 0.28);
}

.user-item.group .user-info span {
  color: #c9bfff;
}

@media (max-width: 620px) {
  .setor-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .setor-actions .mini-btn {
    flex: 1;
  }
}


/* =========================================================
   ETAPA 3.4 - CRIAR CONVERSA EM GRUPO
   ========================================================= */

.sidebar-section-title-actions {
  align-items: center;
}

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

.mini-btn-plus {
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
}

.grupo-modal {
  width: min(720px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(13, 31, 43, 0.96);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.grupo-form {
  padding: 18px;
  overflow-y: auto;
}

.grupo-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
}

.grupo-list-header strong {
  color: var(--text);
}

.grupo-users-list {
  max-height: 360px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.grupo-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
}

.grupo-user-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.grupo-user-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.small-avatar {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border-radius: 12px;
  font-size: 14px;
}

.grupo-note {
  padding: 12px;
  border-radius: 14px;
  background: rgba(32, 134, 194, 0.12);
  border: 1px solid rgba(32, 134, 194, 0.22);
  color: #b9e5f5;
  font-size: 13px;
}

@media (max-width: 560px) {
  .sidebar-section-title-actions {
    align-items: flex-start;
  }

  .sidebar-title-actions {
    width: 100%;
    justify-content: space-between;
  }

  .grupo-modal {
    width: calc(100% - 16px);
  }
}


/* =========================================================
   ETAPA 3.5 - USUÁRIO ATIVO / INATIVO
   ========================================================= */

.bloqueio-modal {
  width: min(430px, 100%);
  padding: 30px;
  text-align: center;
  background: rgba(13, 31, 43, 0.98);
  border: 1px solid rgba(201, 63, 74, 0.32);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.blocked-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 24px;
  background: rgba(201, 63, 74, 0.18);
  font-size: 34px;
}

.bloqueio-modal h2 {
  margin: 0 0 8px;
}

.bloqueio-modal p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.45;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.admin-table .mini-btn.danger-mini {
  background: var(--danger);
}

.admin-table .mini-btn.success-mini {
  background: var(--success);
}

.user-inactive-row {
  opacity: 0.62;
}

.user-inactive-row td {
  background: rgba(201, 63, 74, 0.045);
}


/* =========================================================
   ETAPA 4 - OTIMIZAÇÃO TOTAL PARA DESKTOP E MOBILE
   ========================================================= */

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

body {
  min-height: 100%;
}

.mobile-nav {
  display: none;
}

@media (min-width: 821px) {
  .sidebar {
    max-height: calc(100vh - 100px);
  }

  .users-list {
    overscroll-behavior: contain;
  }

  .messages {
    overscroll-behavior: contain;
  }
}

@media (max-width: 820px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    background:
      radial-gradient(circle at top left, rgba(32, 134, 194, 0.18), transparent 34%),
      var(--bg);
  }

  .auth-screen {
    min-height: 100dvh;
    padding: 14px;
  }

  .auth-card {
    padding: 20px;
    border-radius: 22px;
  }

  .brand h1 {
    font-size: 22px;
  }

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

  input,
  .admin-form select {
    min-height: 48px;
    font-size: 16px;
  }

  .btn {
    min-height: 46px;
    padding: 12px 13px;
  }

  .app {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    min-height: 64px;
    height: auto;
    padding: 9px 10px;
    align-items: center;
    gap: 8px;
  }

  .topbar-brand {
    min-width: 0;
    flex: 1;
  }

  .topbar-brand .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    font-size: 18px;
  }

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

  .topbar-brand span {
    max-width: 44vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
  }

  .topbar-actions {
    width: auto;
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
  }

  .topbar-actions .btn {
    min-height: 38px;
    padding: 9px 10px;
    border-radius: 12px;
    font-size: 12px;
  }

  .topbar-actions #btnAtualizarUsuarios {
    display: none;
  }

  .layout,
  .layout.with-meeting {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    padding: 8px 8px 78px;
    gap: 0;
    overflow: hidden;
  }

  .sidebar,
  .chat,
  .meeting-panel {
    height: 100%;
    min-height: 0;
    max-height: none;
    border-radius: 18px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
  }

  body.mobile-view-conversas .sidebar {
    display: flex;
  }

  body.mobile-view-conversas .chat,
  body.mobile-view-conversas .meeting-panel {
    display: none;
  }

  body.mobile-view-chat .chat {
    display: flex;
  }

  body.mobile-view-chat .sidebar,
  body.mobile-view-chat .meeting-panel {
    display: none;
  }

  body.mobile-view-reuniao .meeting-panel {
    display: flex;
  }

  body.mobile-view-reuniao .sidebar,
  body.mobile-view-reuniao .chat {
    display: none;
  }

  .sidebar-header,
  .chat-header,
  .meeting-header {
    padding: 12px;
  }

  .sidebar-header h2,
  .chat-header h2,
  .meeting-header h2 {
    font-size: 16px;
  }

  .chat-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .chat-header p,
  .meeting-header p {
    font-size: 12px;
  }

  .search {
    margin: 10px 12px;
    width: calc(100% - 24px);
  }

  .sidebar-section-title {
    padding: 6px 12px 7px;
  }

  .users-list {
    padding: 0 8px 10px;
    overflow-y: auto;
  }

  .compact-list {
    max-height: none;
  }

  .user-item {
    min-height: 64px;
    padding: 10px;
    border-radius: 15px;
  }

  .avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 14px;
  }

  .messages {
    padding: 12px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .message {
    max-width: 88%;
    padding: 10px 11px;
    border-radius: 15px;
    font-size: 14px;
  }

  .message.system {
    max-width: 96%;
  }

  .message-form {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px;
  }

  .message-form input {
    min-height: 46px;
  }

  .message-form .btn {
    min-width: 82px;
    min-height: 46px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .btn.meet {
    width: 100%;
  }

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

  .meeting-header {
    align-items: stretch;
    flex-direction: column;
  }

  .meet-box {
    min-height: 0;
    height: 100%;
  }

  .mobile-nav {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 800;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(7, 19, 27, 0.94);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(18px);
  }

  .mobile-nav-btn {
    min-width: 0;
    min-height: 54px;
    display: grid;
    place-items: center;
    gap: 2px;
    border: 0;
    border-radius: 15px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-nav-btn span {
    font-size: 18px;
    line-height: 1;
  }

  .mobile-nav-btn strong {
    display: block;
    font-size: 10.5px;
    line-height: 1;
  }

  .mobile-nav-btn.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(32, 134, 194, 0.75), rgba(124, 77, 255, 0.65));
  }

  .mobile-nav-btn.has-meeting {
    color: #fff;
  }

  .mobile-nav-btn:disabled {
    opacity: 0.45;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 78px;
    max-width: none;
    font-size: 13px;
    padding: 12px 13px;
  }

  .modal-overlay {
    padding: 8px;
    place-items: end center;
  }

  .admin-modal,
  .grupo-modal,
  .bloqueio-modal {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 20px);
    border-radius: 22px 22px 18px 18px;
  }

  .admin-modal {
    height: calc(100dvh - 20px);
  }

  .modal-header {
    padding: 12px;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .admin-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px 12px;
  }

  .admin-tab {
    min-height: 42px;
    padding: 10px;
    font-size: 13px;
  }

  .admin-panel {
    padding: 10px;
  }

  .admin-grid,
  .admin-grid.two {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .admin-card {
    padding: 12px;
    border-radius: 16px;
  }

  .admin-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .table-wrap {
    max-height: 48dvh;
    overflow: auto;
  }

  .admin-table {
    min-width: 720px;
    font-size: 12px;
  }

  .admin-table th,
  .admin-table td {
    padding: 9px 8px;
  }

  .table-actions {
    min-width: 150px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .setor-item {
    align-items: stretch;
    flex-direction: column;
  }

  .setor-actions {
    justify-content: stretch;
  }

  .setor-actions .mini-btn {
    flex: 1;
  }

  .grupo-form {
    padding: 12px;
  }

  .grupo-users-list {
    max-height: 44dvh;
  }

  .bloqueio-modal {
    padding: 24px 18px;
  }
}

@media (max-width: 420px) {
  .topbar {
    padding: 8px;
  }

  .topbar-actions .btn {
    padding: 8px;
    font-size: 11px;
  }

  .topbar-actions #btnAdmin {
    display: none;
  }

  .layout,
  .layout.with-meeting {
    padding-left: 6px;
    padding-right: 6px;
  }

  .mobile-nav {
    left: 6px;
    right: 6px;
    bottom: 6px;
  }

  .message {
    max-width: 92%;
  }

  .message-form {
    grid-template-columns: 1fr;
  }

  .message-form .btn {
    width: 100%;
  }
}

@media (orientation: landscape) and (max-width: 820px) {
  .topbar {
    min-height: 54px;
  }

  .layout,
  .layout.with-meeting {
    padding-bottom: 66px;
  }

  .mobile-nav {
    min-height: 54px;
  }

  .mobile-nav-btn {
    min-height: 44px;
  }

  .mobile-nav-btn span {
    display: none;
  }

  .toast {
    bottom: 66px;
  }
}


/* =========================================================
   ETAPA 4.1 - CORREÇÃO WEBRTC / JITSI FUNCIONAL
   ========================================================= */

.webrtc-fallback {
  height: 100%;
  min-height: 360px;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at top, rgba(124, 77, 255, 0.18), transparent 35%),
    rgba(0, 0, 0, 0.26);
}

.webrtc-icon {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border-radius: 26px;
  background: linear-gradient(135deg, var(--meet), var(--primary));
  font-size: 34px;
  box-shadow: 0 15px 35px rgba(124, 77, 255, 0.22);
}

.webrtc-fallback h3 {
  margin: 0;
  font-size: 22px;
}

.webrtc-fallback p {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.5;
}

.meeting-link-box {
  max-width: 720px;
  display: grid;
  gap: 6px;
  margin: 0 auto;
  padding: 13px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.meeting-link-box span {
  color: var(--muted);
  font-size: 12px;
}

.meeting-link-box strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.meeting-fallback-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.meeting-fallback-actions a.btn {
  text-decoration: none;
}

.webrtc-fallback small {
  display: block;
  max-width: 640px;
  margin: 0 auto;
  color: rgba(238, 247, 251, 0.62);
  line-height: 1.45;
}

@media (max-width: 820px) {
  .webrtc-fallback {
    min-height: 0;
    align-content: center;
    padding: 18px 14px;
  }

  .webrtc-fallback h3 {
    font-size: 19px;
  }

  .meeting-fallback-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .meeting-fallback-actions .btn {
    width: 100%;
  }
}


/* =========================================================
   ETAPA 5 - LOUSA DE ANOTAÇÕES
   ========================================================= */

.btn.board {
  background: linear-gradient(135deg, #f6a623, #ffcc66);
  color: #18212b;
  white-space: nowrap;
}

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

.lousa-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(13, 31, 43, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.lousa-header h2 {
  margin: 0;
  font-size: 18px;
}

.lousa-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lousa-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.lousa-toolbar .btn {
  min-height: 42px;
  padding: 10px;
  font-size: 13px;
}

.lousa-body {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
}

.lousa-body label {
  color: var(--muted);
  font-size: 13px;
}

.lousa-select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}

.lousa-select option {
  color: #111;
}

#lousaTexto {
  flex: 1;
  min-height: 340px;
  width: 100%;
  resize: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    rgba(255, 255, 255, 0.055);
  background-size: 100% 32px;
  color: var(--text);
  border-radius: 18px;
  padding: 18px;
  outline: none;
  line-height: 32px;
  font-size: 16px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

#lousaTexto:focus,
.lousa-select:focus {
  border-color: rgba(42, 167, 238, 0.8);
  box-shadow: 0 0 0 4px rgba(42, 167, 238, 0.12);
}

.lousa-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

@media (min-width: 1180px) {
  .layout.with-lousa {
    grid-template-columns: 300px minmax(360px, 1fr) minmax(390px, 0.9fr);
  }

  .layout.with-lousa.with-meeting {
    grid-template-columns: 260px minmax(340px, 1fr) minmax(340px, 0.75fr) minmax(340px, 0.75fr);
  }
}

@media (max-width: 820px) {
  body.mobile-view-lousa .lousa-panel {
    display: flex;
  }

  body.mobile-view-lousa .sidebar,
  body.mobile-view-lousa .chat,
  body.mobile-view-lousa .meeting-panel {
    display: none;
  }

  body.mobile-view-conversas .lousa-panel,
  body.mobile-view-chat .lousa-panel,
  body.mobile-view-reuniao .lousa-panel {
    display: none;
  }

  .mobile-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .mobile-nav-btn.has-board {
    color: #fff;
  }

  .chat-header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chat-header-actions .btn {
    width: 100%;
  }

  .lousa-panel {
    height: 100%;
    min-height: 0;
    border-radius: 18px;
  }

  .lousa-header {
    padding: 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .lousa-header h2 {
    font-size: 16px;
  }

  .lousa-toolbar {
    grid-template-columns: 1fr 1fr;
    padding: 10px;
  }

  .lousa-body {
    padding: 10px;
  }

  #lousaTexto {
    min-height: 0;
    font-size: 15px;
    line-height: 30px;
    background-size: 100% 30px;
    padding: 14px;
  }

  .lousa-status {
    text-align: left;
  }
}

@media (max-width: 420px) {
  .mobile-nav-btn strong {
    font-size: 9px;
  }

  .mobile-nav-btn span {
    font-size: 16px;
  }

  .lousa-toolbar {
    grid-template-columns: 1fr;
  }

  .chat-header-actions {
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   ETAPA 5.1 - LOUSA GERAL PARA TODOS OS USUÁRIOS
   ========================================================= */

.lousa-autores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 12px;
}

.lousa-autores strong {
  color: var(--text);
}

@media (max-width: 820px) {
  .lousa-autores {
    grid-template-columns: 1fr;
  }
}
