:root {
  --mz-bg: #020617;
  --mz-panel: rgba(15, 23, 42, 0.82);
  --mz-panel-strong: rgba(15, 23, 42, 0.96);
  --mz-border: rgba(148, 163, 184, 0.18);
  --mz-muted: #94a3b8;
  --mz-text: #e5e7eb;
  --mz-blue: #2563eb;
  --mz-green: #16a34a;
  --mz-cyan: #38bdf8;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(
      circle at top left,
      rgba(37, 99, 235, 0.18),
      transparent 32rem
    ),
    radial-gradient(
      circle at top right,
      rgba(22, 163, 74, 0.14),
      transparent 26rem
    ),
    #020617;
  color: var(--mz-text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(96, 165, 250, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96, 165, 250, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 78%);
  z-index: 0;
}

a {
  text-decoration: none;
}

.mz-shell {
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.mz-auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  position: relative;
  z-index: 1;
}
.mz-auth-grid {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: center;
}
@media (min-width: 960px) {
  .mz-auth-grid {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

.mz-auth-hero,
.mz-card,
.mz-table-card,
.mz-panel-card {
  border: 1px solid var(--mz-border);
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.92),
    rgba(2, 6, 23, 0.78)
  );
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.mz-auth-hero {
  border-radius: 2rem;
  padding: clamp(1.5rem, 4vw, 3rem);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
}
.mz-auth-hero::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  right: -80px;
  bottom: -80px;
  filter: blur(8px);
}
.mz-auth-card {
  border-radius: 2rem;
  border: 1px solid var(--mz-border);
  background: rgba(15, 23, 42, 0.86);
  padding: clamp(1.25rem, 3vw, 2rem);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.38);
}

.mz-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
}
.mz-logo-icon {
  width: 2.85rem;
  height: 2.85rem;
  border-radius: 1rem;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #16a34a);
  box-shadow: 0 0 34px rgba(56, 189, 248, 0.28);
}
.mz-logo-title {
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}
.mz-logo-subtitle {
  font-size: 0.74rem;
  color: var(--mz-muted);
  margin-top: 0.2rem;
}

.mz-admin-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px minmax(0, 1fr);
}
.mz-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--mz-border);
  background: rgba(2, 6, 23, 0.84);
  backdrop-filter: blur(18px);
  padding: 1.2rem;
  z-index: 40;
}
.mz-main {
  min-width: 0;
}
.mz-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  border-bottom: 1px solid var(--mz-border);
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem clamp(1rem, 3vw, 1.8rem);
}
.mz-content {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.8rem);
}

.mz-mobile-toggle {
  display: none;
  border: 1px solid var(--mz-border);
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  border-radius: 0.9rem;
  padding: 0.6rem 0.75rem;
}
.mz-overlay {
  display: none;
}

.mz-nav {
  display: grid;
  gap: 0.35rem;
  margin-top: 1.4rem;
}
.mz-nav-link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border-radius: 0.95rem;
  padding: 0.78rem 0.9rem;
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.9rem;
  transition: 0.18s ease;
}
.mz-nav-link:hover,
.mz-nav-link.is-active {
  background: rgba(37, 99, 235, 0.14);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.16);
}
.mz-nav-icon {
  width: 1.1rem;
  text-align: center;
  opacity: 0.95;
}
.mz-sidebar-footer {
  position: absolute;
  left: 1.2rem;
  right: 1.2rem;
  bottom: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--mz-border);
}

.mz-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.26rem 0.62rem;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(148, 163, 184, 0.1);
  color: #cbd5e1;
}
.mz-badge-admin {
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.13);
  border-color: rgba(34, 197, 94, 0.32);
}
.mz-badge-ok {
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.13);
  border-color: rgba(34, 197, 94, 0.32);
}
.mz-badge-warn {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}
.mz-badge-danger {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.34);
}
.mz-badge-muted {
  color: #cbd5e1;
  background: rgba(100, 116, 139, 0.14);
  border-color: rgba(148, 163, 184, 0.24);
}

.mz-page-title {
  font-size: clamp(1.45rem, 3vw, 2.05rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.04em;
}
.mz-page-subtitle {
  color: var(--mz-muted);
  font-size: 0.92rem;
  margin-top: 0.35rem;
}
.mz-card {
  border-radius: 1.35rem;
  padding: 1rem;
}
.mz-panel-card {
  border-radius: 1.35rem;
  padding: 1.1rem;
}
.mz-table-card {
  border-radius: 1.35rem;
  overflow: hidden;
}

button,
.mz-btn,
a[class*="bg-blue"],
a[class*="bg-emerald"],
a[class*="bg-red"],
a[class*="bg-indigo"],
a[class*="bg-slate"],
button[class*="bg-blue"],
button[class*="bg-emerald"],
button[class*="bg-red"],
button[class*="bg-indigo"],
button[class*="bg-slate"] {
  transition:
    transform 0.16s ease,
    background-color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}
button:hover,
.mz-btn:hover,
a[class*="bg-"]:hover {
  transform: translateY(-1px);
}
.mz-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  border-radius: 0.9rem;
  padding: 0.72rem 1rem;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, #2563eb, #16a34a);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.22);
}
.mz-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--mz-border);
  border-radius: 0.9rem;
  padding: 0.72rem 1rem;
  color: #e5e7eb;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.78);
}

input,
select,
textarea {
  color-scheme: dark;
}
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  border-radius: 0.9rem !important;
  background: rgba(2, 6, 23, 0.7) !important;
  border-color: rgba(148, 163, 184, 0.22) !important;
}
input:focus,
select:focus,
textarea:focus {
  border-color: rgba(59, 130, 246, 0.85) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12) !important;
}

.table-modern table,
table {
  border-collapse: separate;
  border-spacing: 0;
}
thead {
  background: rgba(15, 23, 42, 0.9) !important;
}
tbody tr {
  transition: background-color 0.15s ease;
}
tbody tr:hover {
  background: rgba(30, 41, 59, 0.42) !important;
}

.mz-stat-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}
@media (min-width: 680px) {
  .mz-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1100px) {
  .mz-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.mz-stat {
  border: 1px solid var(--mz-border);
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.92),
    rgba(15, 23, 42, 0.62)
  );
  border-radius: 1.2rem;
  padding: 1rem;
}

/* ============ CHAT THREAD STYLES ============ */
.chat-thread-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  padding: 0.5rem 0;
  scroll-behavior: smooth;
}
.chat-thread::-webkit-scrollbar {
  width: 6px;
}
.chat-thread::-webkit-scrollbar-track {
  background: transparent;
}
.chat-thread::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 3px;
}
.chat-thread::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

.chat-message {
  display: flex;
  animation: slideIn 0.2s ease-out;
}

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

.chat-message.client {
  justify-content: flex-start;
}
.chat-message.agent {
  justify-content: flex-end;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 0.875rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.chat-message.client .chat-bubble {
  background: rgba(30, 41, 59, 0.8);
  color: #e5e7eb;
  border-bottom-left-radius: 0.25rem;
}

.chat-message.agent .chat-bubble {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.85),
    rgba(5, 150, 105, 0.85)
  );
  color: #ffffff;
  border-bottom-right-radius: 0.25rem;
}

.chat-bubble-author {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  opacity: 0.9;
}

.chat-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble-time {
  font-size: 0.75rem;
  margin-top: 0.4rem;
  opacity: 0.75;
}

/* ============ ATENDIMENTO DETAIL CHAT ============ */
.atendimento-detail-page {
  display: grid;
  gap: 1rem;
}

.atendimento-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.atendimento-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  margin-top: 0.45rem;
  color: var(--mz-muted);
  font-size: 0.82rem;
}

.atendimento-header-meta span {
  min-width: 0;
}

.atendimento-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
}

.mz-btn-danger,
.mz-btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 0.9rem;
  padding: 0.72rem 1rem;
  font-size: 0.78rem;
  font-weight: 800;
}

.mz-btn-danger {
  border: 0;
  color: #fff;
  background: #dc2626;
  box-shadow: 0 14px 30px rgba(220, 38, 38, 0.18);
}

.mz-btn-danger:hover {
  background: #ef4444;
}

.mz-btn-danger-outline {
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  background: rgba(127, 29, 29, 0.18);
}

.mz-btn-danger-outline:hover {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(127, 29, 29, 0.28);
}

.mz-btn-danger:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.atendimento-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 1rem;
  align-items: stretch;
}

.atendimento-chat-panel,
.atendimento-side-card {
  border: 1px solid var(--mz-border);
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.92),
    rgba(2, 6, 23, 0.82)
  );
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
}

.atendimento-chat-panel {
  min-height: min(720px, calc(100vh - 190px));
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  overflow: hidden;
  border-radius: 1rem;
}

.atendimento-chat-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--mz-border);
  background: rgba(15, 23, 42, 0.78);
}

.atendimento-chat-titlebar h2,
.atendimento-side-card h2 {
  margin: 0;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 850;
}

.atendimento-chat-titlebar p {
  margin: 0.2rem 0 0;
  color: var(--mz-muted);
  font-size: 0.78rem;
}

.atendimento-live-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(34, 197, 94, 0.32);
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.12);
  font-size: 0.72rem;
  font-weight: 800;
}

.atendimento-messages {
  overflow-y: auto;
  padding: 1rem;
  background:
    linear-gradient(rgba(15, 23, 42, 0.24) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.24) 1px, transparent 1px),
    rgba(2, 6, 23, 0.35);
  background-size: 32px 32px;
}

.atendimento-messages::-webkit-scrollbar {
  width: 0.55rem;
}

.atendimento-messages::-webkit-scrollbar-track {
  background: rgba(2, 6, 23, 0.35);
}

.atendimento-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.34);
}

.atendimento-message-list {
  display: grid;
  gap: 0.8rem;
}

.atendimento-empty {
  margin: 0;
  color: var(--mz-muted);
  font-size: 0.86rem;
}

.atendimento-message-row {
  display: flex;
  width: 100%;
}

.atendimento-message-row.is-client {
  justify-content: flex-start;
}

.atendimento-message-row.is-agent {
  justify-content: flex-end;
}

.atendimento-message-row.is-system {
  justify-content: center;
}

.atendimento-bubble {
  max-width: min(78%, 720px);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 1rem;
  padding: 0.78rem 0.9rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.atendimento-message-row.is-client .atendimento-bubble {
  border-bottom-left-radius: 0.3rem;
  background: rgba(30, 41, 59, 0.92);
  color: #e5e7eb;
}

.atendimento-message-row.is-agent .atendimento-bubble {
  border-bottom-right-radius: 0.3rem;
  border-color: rgba(52, 211, 153, 0.32);
  background: linear-gradient(135deg, #047857, #059669);
  color: #fff;
}

.atendimento-message-row.is-system .atendimento-bubble {
  max-width: min(86%, 620px);
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.78);
  color: #cbd5e1;
  text-align: center;
}

.atendimento-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.42rem;
  font-size: 0.72rem;
  opacity: 0.86;
}

.atendimento-bubble-meta strong,
.atendimento-bubble-meta span {
  min-width: 0;
}

.atendimento-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1.5;
}

.atendimento-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  padding: 0.85rem;
  border-top: 1px solid var(--mz-border);
  background: rgba(15, 23, 42, 0.94);
}

.atendimento-composer textarea {
  min-height: 3.25rem;
  max-height: 10rem;
  resize: vertical;
  padding: 0.82rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.atendimento-send-btn {
  min-height: 3.25rem;
  padding-inline: 1.25rem;
}

.atendimento-sidebar {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.atendimento-side-card {
  border-radius: 1rem;
  padding: 1rem;
}

.atendimento-info-list {
  display: grid;
  gap: 0.85rem;
  margin: 0.9rem 0 0;
}

.atendimento-info-list div {
  display: grid;
  gap: 0.24rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.atendimento-info-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.atendimento-info-list dt,
.atendimento-close-form span {
  color: var(--mz-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.atendimento-info-list dd {
  margin: 0;
  color: #e5e7eb;
  font-size: 0.88rem;
}

.atendimento-close-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.9rem;
}

.atendimento-close-form label {
  display: grid;
  gap: 0.45rem;
}

.atendimento-close-form input,
.atendimento-close-form textarea {
  width: 100%;
  padding: 0.72rem 0.8rem;
  font-size: 0.82rem;
  line-height: 1.45;
}

.atendimento-close-form textarea:disabled {
  color: #cbd5e1;
  opacity: 0.75;
}

@media (max-width: 1080px) {
  .atendimento-layout {
    grid-template-columns: 1fr;
  }

  .atendimento-chat-panel {
    min-height: 680px;
  }
}

@media (max-width: 680px) {
  .atendimento-header {
    display: grid;
  }

  .atendimento-header-actions {
    justify-content: stretch;
  }

  .atendimento-header-actions > * {
    flex: 1 1 0;
  }

  .atendimento-chat-panel {
    min-height: calc(100vh - 150px);
  }

  .atendimento-chat-titlebar {
    align-items: flex-start;
  }

  .atendimento-messages {
    padding: 0.75rem;
  }

  .atendimento-bubble {
    max-width: 90%;
  }

  .atendimento-message-row.is-system .atendimento-bubble {
    max-width: 96%;
  }

  .atendimento-composer {
    grid-template-columns: 1fr;
  }

  .atendimento-send-btn {
    width: 100%;
  }
}
.mz-stat-label {
  color: var(--mz-muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.mz-stat-value {
  font-size: 1.8rem;
  line-height: 1;
  font-weight: 850;
  letter-spacing: -0.05em;
  margin-top: 0.65rem;
  color: #fff;
}

@media (max-width: 880px) {
  .mz-admin-shell {
    display: block;
  }
  .mz-sidebar {
    position: fixed;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    width: min(86vw, 310px);
  }
  body.mz-sidebar-open .mz-sidebar {
    transform: translateX(0);
  }
  .mz-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.55);
  }
  body.mz-sidebar-open .mz-overlay {
    display: block;
  }
  .mz-mobile-toggle {
    display: inline-flex;
  }
  .mz-topbar {
    min-height: 64px;
  }
  .mz-content {
    padding: 1rem;
  }
}

@media (max-width: 640px) {
  .max-w-6xl,
  .max-w-5xl {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  table {
    min-width: 760px;
  }
}
