/* =========================================================
   HelpDesk SaaS — Estilos consolidados e responsivos
   ========================================================= */

:root {
  --primary:#2563eb;
  --primary-dark:#1d4ed8;
  --primary-light:#dbeafe;
  --success:#16a34a;
  --error:#dc2626;
  --warning:#f59e0b;
  --info:#0ea5e9;
  --bg:#f1f5f9;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;
  --sidebar-w:250px;
  --header-h:60px;
  --radius:10px;
  --shadow:0 1px 3px rgba(0,0,0,.08);
}

/* =========================================================
   RESET + BLINDAGEM RESPONSIVA
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

img, video, iframe, svg, canvas { max-width: 100%; height: auto; }

body, p, div, span, td, th, li, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

code, pre, a { word-break: break-word; }
pre { white-space: pre-wrap; overflow-x: auto; max-width: 100%; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Container global ---------- */
.container {
  width: 100%;
  max-width: 1200px;
  padding-left: 16px;
  padding-right: 16px;
  margin: 0 auto;
}

/* =========================================================
   TOPBAR
   ========================================================= */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  z-index: 1000;         /* ↑ aumentei para ficar sobre tudo */
  box-shadow: var(--shadow);
  max-width: 100vw;
  /* overflow: hidden;  ← REMOVIDO */
}

.hamburger {
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text);
  flex-shrink: 0;
}
.hamburger:hover { background: var(--bg); }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 20px; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.badge-empresa {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Dropdown usuário ---------- */
/* ---------- Dropdown usuário ---------- */
.user-dropdown { position: relative; }

.user-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.user-btn:hover { background: var(--bg); }

.user-dropdown .dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 180px;
  list-style: none;
  padding: 6px;
  margin: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  display: none;
  z-index: 300;
}

/* ✅ Abre via JS (classe .open) OU hover no desktop */
.user-dropdown.open .dropdown,
.user-dropdown:hover .dropdown {
  display: block;
  animation: dropdownFade .15s ease;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown li a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
.dropdown li a:hover { background: var(--bg); text-decoration: none; }

.user-dropdown .dropdown li.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  padding: 0;
}

/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  max-width: 85vw;
  background: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0;
  z-index: 90;
  transition: transform .25s ease;
}

.sidebar-nav { padding: 0 12px; }

.nav-group {
  display: block;
  padding: 12px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .05em;
}

.nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; font-weight: 600; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 80;
  display: none;
}
.overlay.show { display: block; }

/* =========================================================
   CONTEÚDO
   ========================================================= */

.content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 24px 16px 60px;
  min-height: calc(100vh - var(--header-h));
  width: calc(100% - var(--sidebar-w));
  max-width: calc(100% - var(--sidebar-w));
  overflow-x: hidden;
}

.page-title { font-size: 24px; margin: 0 0 8px; }

/* =========================================================
   CARDS DE MÉTRICA
   ========================================================= */

.cards {
  display: grid;
  gap: 16px;
  margin-top: 20px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  width: 100%;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-label {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.card-value {
  font-size: 32px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--primary);
}

/* =========================================================
   BOTÕES
   ========================================================= */

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.actions { margin-top: 24px; }

/* =========================================================
   ALERTAS
   ========================================================= */

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background:#dcfce7; color:#166534; border-color:#bbf7d0; }
.alert-error   { background:#fee2e2; color:#991b1b; border-color:#fecaca; }
.alert-warning { background:#fef3c7; color:#92400e; border-color:#fde68a; }
.alert-info    { background:#dbeafe; color:#1e40af; border-color:#bfdbfe; }

/* =========================================================
   FORMULÁRIOS
   ========================================================= */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }

.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  line-height: 1.4;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--primary-light);
  border-color: var(--primary);
}

textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
  width: 100%;
}

input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.checkbox-field {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.checkbox-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.checkbox-field span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text) !important;
}

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 900px;
}

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  width: 100%;
}
.form-grid .span-2 { grid-column: span 2; }

.form-section {
  margin: 20px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}
.form-section:first-child { margin-top: 0; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* =========================================================
   LOGIN / PORTAL
   ========================================================= */

.login-body {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .brand-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.login-brand h1 { margin: 0; font-size: 26px; color: var(--text); }
.login-brand p { margin: 4px 0 0; }
.login-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.login-hint {
  text-align: center;
  color: #fff;
  margin-top: 20px;
  font-size: 13px;
}
.login-hint code {
  background: rgba(255,255,255,.2);
  padding: 2px 6px;
  border-radius: 4px;
}

/* =========================================================
   FOOTER
   ========================================================= */

.footer {
  margin-left: var(--sidebar-w);
  padding: 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  color: var(--muted);
  max-width: 100%;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}

/* =========================================================
   PAGE-HEAD / FILTROS
   ========================================================= */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  width: 100%;
}
.page-head > div:first-child { min-width: 0; flex: 1; }
.page-head .actions,
.page-head > a { flex-shrink: 0; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: 16px;
  background: var(--card);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
}

.filters input[type="text"],
.filters input[type="month"],
.filters input[type="date"],
.filters select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  min-width: 0;
  flex: 1 1 180px;
  max-width: 100%;
  height: 42px;
}

.filters input[type="text"]:focus,
.filters select:focus {
  outline: 2px solid var(--primary-light);
  border-color: var(--primary);
}

.filters .btn {
  padding: 9px 16px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
}

/* =========================================================
   TABELA — DESKTOP
   ========================================================= */

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}

.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafc; }
.table .text-right { text-align: right; }
.table .text-center { text-align: center; }

.table-bordered td, .table-bordered th { border-bottom: 1px solid var(--border); }
.table-bordered th {
  width: 140px;
  background: #f8fafc;
  font-weight: 600;
  color: var(--text);
}

.table .actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.actions .btn { white-space: nowrap; }

/* =========================================================
   BADGES
   ========================================================= */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.badge-trial     { background:#e0e7ff; color:#3730a3; }
.badge-ativo     { background:#dcfce7; color:#166534; }
.badge-suspenso  { background:#fef3c7; color:#92400e; }
.badge-cancelado { background:#fee2e2; color:#991b1b; }
.badge-pendente  { background:#fef3c7; color:#92400e; }
.badge-bloqueado { background:#fee2e2; color:#991b1b; }

.badge-nivel-superadmin   { background:#ede9fe; color:#5b21b6; }
.badge-nivel-adminempresa { background:#dbeafe; color:#1e40af; }
.badge-nivel-atendente    { background:#dcfce7; color:#166534; }
.badge-nivel-cliente      { background:#f1f5f9; color:#475569; }

.badge-prio-baixa   { background:#dcfce7; color:#166534; }
.badge-prio-media   { background:#dbeafe; color:#1e40af; }
.badge-prio-alta    { background:#fef3c7; color:#92400e; }
.badge-prio-urgente { background:#fee2e2; color:#991b1b; }

.badge-aberto      { background:#fef3c7; color:#92400e; }
.badge-andamento   { background:#dbeafe; color:#1e40af; }
.badge-aguardando  { background:#e0e7ff; color:#3730a3; }
.badge-resolvido   { background:#dcfce7; color:#166534; }
.badge-fechado     { background:#f1f5f9; color:#475569; }

/* =========================================================
   PAGINAÇÃO
   ========================================================= */

.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* =========================================================
   PAINÉIS / GRID 2
   ========================================================= */

.grid-2 {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.panel h3 { margin: 0 0 14px; font-size: 16px; }

/* =========================================================
   CHAMADOS
   ========================================================= */

.chamado-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.chamado-main { min-width: 0; max-width: 100%; }
.chamado-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.mensagens {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  min-width: 0;
}
.msg-cliente { background:#f8fafc; border-left:3px solid var(--primary); }
.msg-staff   { background:#eff6ff; border-left:3px solid #16a34a; }
.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}
.msg-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}

.resposta-form textarea { margin-bottom: 10px; }
.resposta-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* =========================================================
   ANEXOS
   ========================================================= */

.msg-anexos {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.anexo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 100%;
}
.anexo-item .anexo-icon { font-size: 22px; }
.anexo-item .anexo-info { display: flex; flex-direction: column; min-width: 0; }
.anexo-item .anexo-info a {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.anexo-item .anexo-info .muted { font-size: 11px; }

.anexo-preview {
  display: block;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.anexo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .2s;
}
.anexo-preview:hover img { transform: scale(1.08); }

.anexo-upload {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.anexo-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: .15s;
}
.anexo-label:hover {
  background: #eff6ff;
  border-color: var(--primary);
  color: var(--primary);
}
.anexo-label input[type="file"] { display: none; }

.upload-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.upload-item.upload-error { background:#fef2f2; border-color:#fecaca; }
.upload-spinner { font-size: 16px; }
.upload-name { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:500; }
.upload-status { font-size:12px; color:var(--muted); }
.upload-remove {
  background: transparent;
  border: 0;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.upload-remove:hover { color: #dc2626; }

/* =========================================================
   NOTA INTERNA
   ========================================================= */

.msg-interna {
  background: #fffbeb !important;
  border: 1px solid #fcd34d !important;
  border-left: 4px solid #f59e0b !important;
  position: relative;
}
.msg-interna-badge {
  display: inline-block;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.msg-interna .msg-head strong { color: #92400e; }

/* =========================================================
   TOGGLE DE TIPO DE RESPOSTA
   ========================================================= */

.tipo-resposta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 20px;
  margin-bottom: 16px;
  padding: 4px 0;
}

.tipo-opcao {
  cursor: pointer;
  display: block;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  transition: all .18s ease;
  background: #fff;
  position: relative;
}
.tipo-opcao input[type="radio"] { position:absolute; opacity:0; pointer-events:none; }
.tipo-conteudo { display: flex; align-items: center; gap: 14px; }
.tipo-icone { font-size: 26px; line-height: 1; flex-shrink: 0; }
.tipo-conteudo strong {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 3px;
  transition: color .18s;
}
.tipo-conteudo small {
  font-size: 12px;
  color: var(--muted);
  display: block;
  transition: color .18s;
}
.tipo-opcao:hover { border-color: #94a3b8; background: #fafbfc; }

.tipo-opcao.tipo-publico.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.tipo-opcao.tipo-publico.active .tipo-conteudo strong { color: #1e40af; }
.tipo-opcao.tipo-publico.active .tipo-conteudo small { color: #2563eb; font-weight: 500; }

.tipo-opcao.tipo-interno.active {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(245,158,11,.18);
}
.tipo-opcao.tipo-interno.active .tipo-conteudo strong { color: #92400e; }
.tipo-opcao.tipo-interno.active .tipo-conteudo small { color: #b45309; font-weight: 500; }

/* =========================================================
   BASE DE CONHECIMENTO
   ========================================================= */

.kb-search { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.kb-search input {
  flex: 1;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  min-width: 0;
}
.kb-search input:focus { outline: 2px solid var(--primary-light); border-color: var(--primary); }

.kb-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}
.kb-side {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 80px;
}
.kb-side h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
.kb-cats { list-style: none; padding: 0; margin: 0; }
.kb-cats li { margin-bottom: 4px; }
.kb-cats a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: .15s;
  gap: 8px;
}
.kb-cats a:hover { background: var(--bg); text-decoration: none; }
.kb-cats a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.kb-count {
  font-size: 11px;
  background: var(--bg);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  flex-shrink: 0;
}
.kb-cats a.active .kb-count { background: #fff; color: var(--primary); }

.kb-main { min-width: 0; }

.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.kb-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  transition: .15s;
  min-height: 180px;
  min-width: 0;
}
.kb-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  text-decoration: none;
  border-color: var(--primary);
}
.kb-card h3 { margin: 10px 0 8px; font-size: 16px; line-height: 1.4; color: var(--text); }
.kb-card .kb-resumo {
  flex: 1;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-cat-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  width: fit-content;
}
.kb-meta { display: flex; gap: 6px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap; }

.kb-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.kb-empty h3 { margin: 0 0 8px; }
.kb-empty .btn { margin-top: 16px; }

.kb-cta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.kb-article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
.kb-article { padding: 32px; min-width: 0; }

.article-content { line-height: 1.7; }
.article-content h2 { font-size:22px; margin:24px 0 12px; color:var(--text); }
.article-content h3 { font-size:18px; margin:20px 0 10px; color:var(--text); }
.article-content p { margin:0 0 14px; color:var(--text); }
.article-content ul, .article-content ol { margin:0 0 14px 22px; padding:0; }
.article-content li { margin-bottom: 6px; }
.article-content code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: monospace;
}
.article-content pre {
  background: #f1f5f9;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: monospace;
}
.article-content a { color: var(--primary); text-decoration: underline; }

.kb-feedback {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.kb-side-article .kb-cta-box {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border: 1px solid #bfdbfe;
}

.kb-relacionados { list-style:none; padding:0; margin:0; }
.kb-relacionados li { padding:8px 0; border-bottom:1px solid var(--border); }
.kb-relacionados li:last-child { border-bottom: 0; }
.kb-relacionados a { font-size:13px; color:var(--text); display:block; line-height:1.4; }
.kb-relacionados a:hover { color: var(--primary); }

/* =========================================================
   TABS / PERFIL
   ========================================================= */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  width: 100%;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.profile-meta {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.profile-meta > div > .muted {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.password-rules {
  margin-top: 20px;
  padding: 14px 18px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.password-rules strong { display:block; margin-bottom:8px; color:var(--text); }
.password-rules ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}
.password-rules li { color: var(--muted); transition: color .15s; }

/* =========================================================
   NOTIFICAÇÕES
   ========================================================= */

.notif-sino {
  position: relative;
  display: inline-block;
  margin-right: 6px;
}

.btn-sino {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
}
.btn-sino:hover { background: var(--bg); border-color: var(--primary); }

.notif-badge-contador {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border-radius: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(220,38,38,.4);
  line-height: 1;
}

@keyframes sinoPisca {
  0%, 100% { transform: rotate(0); }
  20%      { transform: rotate(-15deg); }
  40%      { transform: rotate(15deg); }
  60%      { transform: rotate(-10deg); }
  80%      { transform: rotate(10deg); }
}
.notif-sino.piscando .btn-sino { animation: sinoPisca .6s ease-in-out 3; }

.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 30px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
  z-index: 9999;
  overflow: hidden;
}
.notif-dropdown.show { display: block; animation: dropdownFade .15s ease; }



.notif-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}
.notif-header strong { font-size: 14px; color: var(--text); }
.notif-header a { font-size: 12px; color: var(--primary); font-weight: 600; }

.notif-lista-drop { max-height: 400px; overflow-y: auto; }

.notif-item-drop {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background .12s;
  cursor: pointer;
}
.notif-item-drop:hover { background: #f8fafc; text-decoration: none; }
.notif-item-drop.nova { background:#eff6ff; border-left:3px solid var(--primary); }
.notif-item-drop.nova:hover { background: #dbeafe; }
.notif-item-drop:last-child { border-bottom: 0; }

.notif-titulo-drop { font-size: 13px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.notif-msg-drop {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-tempo-drop { font-size: 11px; color: #94a3b8; font-weight: 600; }
.notif-vazio { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13px; }

.notif-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  background: #f8fafc;
}
.notif-footer a { font-size: 13px; font-weight: 600; color: var(--primary); }

/* Página /notificacoes.php */
.notif-lista { display: flex; flex-direction: column; gap: 8px; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all .15s;
}
.notif-item:hover { border-color: #94a3b8; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.notif-item.notif-nova { background: #eff6ff; border-left: 4px solid var(--primary); }
.notif-item.notif-lida { opacity: .75; }

.notif-icone { font-size: 24px; line-height: 1; flex-shrink: 0; }
.notif-corpo { flex: 1; min-width: 0; }
.notif-titulo { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.notif-titulo strong { font-size: 14px; color: var(--text); }
.notif-badge {
  background: var(--primary);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: .05em;
}
.notif-mensagem { font-size: 13px; color: var(--muted); margin: 0 0 6px; line-height: 1.5; }
.notif-meta { font-size: 12px; color: #94a3b8; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.notif-meta a { font-weight: 600; color: var(--primary); }

/* =========================================================
   RESPONSIVO GERAL
   ========================================================= */

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: 2px 0 10px rgba(0,0,0,.1); }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; width: 100%; max-width: 100%; padding: 16px 12px 60px; }
  .footer { margin-left: 0; }
  .chamado-grid { grid-template-columns: 1fr; }
  .kb-layout { grid-template-columns: 1fr; }
  .kb-side { position: static; }
  .kb-article-layout { grid-template-columns: 1fr; }
  .kb-side-article { order: -1; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .badge-empresa { display: none; }
}

@media (max-width: 600px) {
  .brand-name { display: none; }
  .user-btn { font-size: 13px; padding: 5px 8px; max-width: 100px; }
  .card-value { font-size: 26px; }
  .login-card { padding: 24px 20px; }
  .page-title { font-size: 20px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .page-head .actions .btn,
  .page-head > a.btn { flex: 1; text-align: center; }

  .form-card { padding: 16px 14px; border-radius: 8px; }
  .form { gap: 10px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-grid .span-2 { grid-column: span 1; }
  .field { gap: 4px; }
  .field span { font-size: 12px; }
  .field input,
  .field select,
  .field textarea {
    padding: 8px 10px;
    font-size: 15px;
    border-radius: 6px;
  }
  input[type="color"] { height: 36px; }
  textarea { min-height: 80px; }
  .form-section { margin: 16px 0 10px; font-size: 14px; padding-bottom: 6px; }
  .form-actions { flex-direction: column-reverse; gap: 8px; margin-top: 16px; padding-top: 14px; }
  .form-actions .btn { width: 100%; padding: 10px 14px; }
  .checkbox-field { padding: 10px; gap: 6px; }
  .checkbox-field input[type="checkbox"] { width: 16px; height: 16px; }
  .checkbox-field span { font-size: 13px; }

  .tipo-resposta { grid-template-columns: 1fr; gap: 10px; }
  .tipo-icone { font-size: 24px; }
  .anexo-item { width: 100%; }
  .anexo-item .anexo-info a { max-width: 140px; }
  .kb-search { flex-direction: column; }
  .kb-search button { width: 100%; }
  .kb-grid { grid-template-columns: 1fr; }
  .kb-article { padding: 20px; }
  .tab { padding: 8px 12px; font-size: 13px; }
}

@media (max-width: 480px) {
  .notif-dropdown { width: calc(100vw - 30px); right: -60px; }
  .notif-item { padding: 12px 14px; }
  .notif-icone { font-size: 20px; }
  .footer-inner { flex-direction: column; align-items: center; text-align: center; }
  .cards { grid-template-columns: 1fr; }
}

/* =========================================================
   FILTROS — MOBILE COMPACTO
   ========================================================= */

@media (max-width: 700px) {
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
  }

  .filters input[type="text"],
  .filters input[type="month"],
  .filters input[type="date"] {
    grid-column: 1 / -1;
    height: 38px;
    padding: 7px 10px;
    font-size: 15px;
  }

  .filters select {
    height: 38px;
    padding: 7px 10px;
    font-size: 15px;
    width: 100%;
  }

  .filters .btn {
    height: 38px;
    padding: 7px 10px;
    font-size: 13px;
    width: 100%;
  }
}

@media (max-width: 380px) {
  .form-card { padding: 12px 10px; }
  .field input, .field select, .field textarea { padding: 7px 9px; font-size: 14px; }
  .form-section { font-size: 13px; }
  .btn { padding: 9px 14px; font-size: 13px; }

  .filters {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }
  .filters select,
  .filters input,
  .filters .btn {
    height: 36px;
    font-size: 14px;
  }
}

/* =========================================================
   ✅ TABELA RESPONSIVA — vira CARDS no mobile
   ========================================================= */

@media (max-width: 700px) {
  .table thead { display: none; }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table { min-width: 0; }

  .table-wrap {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    overflow: visible;
  }

  .table tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }

  .table tr:last-child { margin-bottom: 0; }

  .table td {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 7px 0 !important;
    border-bottom: 1px solid var(--border) !important;
    text-align: right;
    font-size: 13px;
    min-height: auto;
    border: 0;
  }

  .table td:last-child {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  .table td:first-child {
    background: #f8fafc;
    margin: -14px -16px 8px -16px !important;
    padding: 10px 16px !important;
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid var(--border) !important;
    font-weight: 700;
    color: var(--primary);
    display: block !important;
    text-align: left;
  }

  .table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    flex-shrink: 0;
    text-align: left;
    min-width: 80px;
  }

  .table td:first-child::before { display: none; }

  .table td:nth-child(2) {
    display: block !important;
    text-align: left;
    font-size: 15px;
    padding: 8px 0 !important;
    font-weight: 600;
  }
  .table td:nth-child(2)::before { display: none; }

  .table td.text-right,
  .table td.actions {
    display: flex !important;
    justify-content: flex-end;
    align-items: center;
    padding-top: 12px !important;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    border-bottom: 0 !important;
    flex-wrap: wrap;
    gap: 6px;
  }

  .table td.text-right::before,
  .table td.actions::before { display: none; }

  .table td.actions .btn {
    padding: 8px 18px;
    font-size: 13px;
    width: auto;
    margin-bottom: 0;
  }

  .table td[colspan] {
    display: block !important;
    text-align: center !important;
    border: 0 !important;
    padding: 40px 20px !important;
    background: transparent !important;
    margin: 0 !important;
    color: var(--muted);
  }
  .table td[colspan]::before { display: none; }
}

@media (max-width: 400px) {
  .table td {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    text-align: left;
  }
  .table td::before { min-width: 0; }
  .table td.text-right,
  .table td.actions { align-items: flex-end; }
}

/* =========================================================
   Avaliação do atendimento
   ========================================================= */

.avaliacao-estrelas {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  justify-content: center;
}

.estrela {
  background: transparent;
  border: 0;
  font-size: 48px;
  line-height: 1;
  color: #cbd5e1;
  cursor: pointer;
  transition: all .15s;
  padding: 4px 8px;
}
.estrela:hover,
.estrela.ativa {
  color: #f59e0b;
  transform: scale(1.1);
}

.avaliacao-texto {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 20px;
  color: var(--muted);
  min-height: 24px;
}

.avaliacao-cta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  margin-top: 20px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fcd34d;
  border-radius: 10px;
  flex-wrap: wrap;
}

.avaliacao-resultado {
  margin-top: 20px;
  padding: 16px 20px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.estrelas-mostradas {
  display: inline-flex;
  gap: 2px;
  font-size: 20px;
  line-height: 1;
}
.estrelas-mostradas span {
  color: #cbd5e1;
}
.estrelas-mostradas span.ativa {
  color: #f59e0b;
}

.avaliacao-panel {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-color: #fcd34d;
}

@media (max-width: 600px) {
  .estrela {
    font-size: 40px;
    padding: 2px 4px;
  }
  .avaliacao-cta {
    flex-direction: column;
    text-align: center;
  }
}

/* =========================================================
   Relatórios — barras e evolução
   ========================================================= */

.barras {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.barra-item {}

.barra-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 4px;
}

.barra-label span {
  font-weight: 500;
  color: var(--text);
}

.barra-label strong {
  color: var(--primary);
  font-weight: 700;
}

.barra-track {
  height: 8px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
}

.barra-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s;
}

/* Evolução diária */
.evolucao {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 180px;
  padding: 16px 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.evolucao-dia {
  flex: 1 0 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 160px;
  position: relative;
  gap: 4px;
}

.evolucao-barra {
  width: 100%;
  max-width: 32px;
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  border-radius: 4px 4px 0 0;
  transition: all .3s;
  min-height: 8px;
}
.evolucao-dia:hover .evolucao-barra {
  background: linear-gradient(180deg, #f59e0b, #d97706);
  transform: scaleY(1.05);
}

.evolucao-numero {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.evolucao-data {
  font-size: 10px;
  color: var(--muted);
}

@media (max-width: 600px) {
  .evolucao {
    padding: 12px 4px 0;
  }
  .evolucao-dia {
    flex: 1 0 28px;
    min-height: 140px;
  }
}
/* =========================================================
   PWA — botão instalar + aviso iOS
   ========================================================= */

.btn-instalar-app {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
}

.btn-instalar-app:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.btn-instalar-app:active {
  transform: translateY(0);
}

@media (max-width: 600px) {
  .btn-instalar-app span {
    display: none;
  }
  .btn-instalar-app {
    padding: 8px 10px;
    font-size: 16px;
  }
}

/* Aviso iOS */
.pwa-ios-aviso {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 400px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  z-index: 9999;
  animation: pwaSlideUp .3s ease;
}

@keyframes pwaSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pwa-ios-conteudo {
  padding: 18px 20px 20px;
  position: relative;
}

.pwa-ios-conteudo strong {
  display: block;
  font-size: 15px;
  margin-bottom: 8px;
  color: var(--text);
}

.pwa-ios-conteudo p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.pwa-ios-fechar {
  position: absolute;
  top: 8px;
  right: 12px;
  background: transparent;
  border: 0;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}

.pwa-ios-fechar:hover {
  color: var(--text);
}

/* Ajuste quando em modo app (sem barra do navegador) */
@media (display-mode: standalone) {
  .topbar {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--header-h) + env(safe-area-inset-top));
  }
  
  .content {
    margin-top: calc(var(--header-h) + env(safe-area-inset-top));
  }
  
  .sidebar {
    top: calc(var(--header-h) + env(safe-area-inset-top));
  }
}
/* =========================================================
   Busca Global — botão + painel dropdown
   ========================================================= */

.busca-wrap {
  position: relative;
  display: inline-block;
}

.btn-busca {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 16px;
  height: 40px;
  color: var(--text);
  transition: all .15s;
}

.btn-busca:hover {
  background: var(--bg);
  border-color: var(--primary);
}

.busca-atalho {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-family: monospace;
}

/* Painel dropdown */
.busca-painel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 480px;
  max-width: calc(100vw - 30px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
  z-index: 9999;
  overflow: hidden;
}

.busca-painel.show {
  display: block;
  animation: dropdownFade .15s ease;
}

.busca-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.busca-header input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
}

.busca-header input:focus {
  outline: 2px solid var(--primary-light);
  border-color: var(--primary);
}

.busca-lista {
  max-height: 480px;
  overflow-y: auto;
}

.busca-vazio,
.busca-carregando {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.busca-grupo {
  border-bottom: 1px solid var(--border);
}

.busca-grupo:last-child {
  border-bottom: 0;
}

.busca-grupo-titulo {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: #f8fafc;
}

.busca-item-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  transition: background .12s;
  border-left: 3px solid transparent;
}

.busca-item-mini:hover {
  background: #f1f5f9;
  text-decoration: none;
  border-left-color: var(--primary);
}

.busca-item-icone {
  font-size: 18px;
  flex-shrink: 0;
}

.busca-item-conteudo {
  flex: 1;
  min-width: 0;
}

.busca-item-titulo {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.busca-item-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.busca-ver-todos {
  display: block;
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

.busca-ver-todos:hover {
  background: #eff6ff;
  text-decoration: none;
}

/* Página completa de busca */
.busca-resultados {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.busca-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
}

.busca-item:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  text-decoration: none;
  transform: translateX(3px);
}

.busca-icone {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.busca-conteudo {
  flex: 1;
  min-width: 0;
}

.busca-titulo {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.busca-subtitulo {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 4px;
}

.busca-data {
  font-size: 11px;
  color: #94a3b8;
}

.busca-tipo {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary-dark);
  flex-shrink: 0;
}

/* Responsivo */
@media (max-width: 700px) {
  .busca-atalho {
    display: none;
  }

  .btn-busca {
    padding: 8px 10px;
    font-size: 18px;
  }

  .busca-painel {
    width: calc(100vw - 20px);
    right: -100px;
  }
}

@media (max-width: 480px) {
  .busca-painel {
    position: fixed;
    top: 70px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    right: 10px;
  }

  .busca-item {
    padding: 12px 14px;
    gap: 12px;
  }

  .busca-icone {
    font-size: 22px;
  }

  .busca-tipo {
    display: none;
  }
}
/* =========================================================
   Dashboard Avançado — KPIs + Gráficos
   ========================================================= */

.dash-periodo {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  flex-wrap: wrap;
}

.periodo-btn {
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.periodo-btn:hover {
  color: var(--text);
}

.periodo-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* KPIs */
.dash-kpis {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-top: 8px;
}

.dash-kpi {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}

.dash-kpi::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
}

.dash-kpi.kpi-blue::before   { background: #2563eb; }
.dash-kpi.kpi-orange::before { background: #f59e0b; }
.dash-kpi.kpi-green::before  { background: #16a34a; }
.dash-kpi.kpi-yellow::before { background: #eab308; }
.dash-kpi.kpi-purple::before { background: #8b5cf6; }
.dash-kpi.kpi-red::before    { background: #dc2626; }

.dash-kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.06);
}

.kpi-icon {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
}

.kpi-content {
  flex: 1;
  min-width: 0;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  transition: opacity .2s;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* Grid de gráficos */
.dash-grid-2 {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
  align-items: start;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 8px;
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Ações rápidas */
.dash-acoes {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.dash-acao {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: all .15s;
  position: relative;
}

.dash-acao:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  text-decoration: none;
  transform: translateY(-2px);
}

.dash-acao-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.dash-acao-titulo {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.dash-acao-count {
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  flex-shrink: 0;
}

/* Responsivo */
@media (max-width: 900px) {
  .dash-grid-2 {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 240px;
  }
}

@media (max-width: 600px) {
  .dash-periodo {
    width: 100%;
    justify-content: center;
  }

  .periodo-btn {
    flex: 1;
    padding: 8px 8px;
    font-size: 12px;
  }

  .dash-kpis {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 22px;
  }

  .chart-wrap {
    height: 220px;
  }

  .dash-acao {
    padding: 12px 14px;
  }

  .dash-acao-icon {
    font-size: 20px;
  }

  .dash-acao-titulo {
    font-size: 13px;
  }
}
/* =========================================================
   Logotipo da empresa
   ========================================================= */

/* Logo no topbar */
.brand-logo {
  height: 36px;
  max-width: 140px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

@media (max-width: 600px) {
  .brand-logo {
    height: 30px;
    max-width: 100px;
  }
}

/* Preview box (página de config) */
.logo-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px 20px;
  background: #f8fafc;
  border: 2px dashed var(--border);
  border-radius: 12px;
  min-height: 200px;
  max-width: 400px;
}

.logo-preview-box img {
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
}

.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Área de upload */
.logo-upload-area {
  margin-top: 16px;
}

.logo-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: #f8fafc;
  transition: all .15s;
  text-align: center;
  max-width: 400px;
}

.logo-upload-label:hover {
  background: #eff6ff;
  border-color: var(--primary);
}

.logo-upload-label input[type="file"] {
  display: none;
}

.logo-upload-icon {
  font-size: 36px;
  line-height: 1;
}

.logo-upload-label strong {
  font-size: 15px;
  color: var(--text);
}

.logo-preview-new {
  margin-top: 20px;
}

/* Preview do logo no portal */
.portal-logo img {
  max-height: 80px;
  border-radius: 12px;
  background: #fff;
  padding: 8px 16px;
  max-width: 240px;
  object-fit: contain;
}

@media (max-width: 600px) {
  .portal-logo img {
    max-height: 60px;
    padding: 6px 12px;
  }
}

/* Complemento do avatar no dropdown */
.dropdown-avatar-initial {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

/* =========================================================
   Avatar do usuário
   ========================================================= */

/* Botão do usuário (topbar) */
.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

.user-avatar-initial {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
}

.user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Header do dropdown do usuário */
.dropdown-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.dropdown-header strong {
  display: block;
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}

.dropdown-header .muted {
  font-size: 11px;
}

.dropdown-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--primary-light);
}

.dropdown-avatar-initial {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

/* Avatar nas mensagens do chamado */
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.msg-avatar-initial {
  background: linear-gradient(135deg, #64748b, #475569);
  color: #fff;
}

.msg-staff .msg-avatar-initial {
  background: linear-gradient(135deg, #16a34a, #15803d);
}

.msg-cliente .msg-avatar-initial {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

/* Página de upload do avatar */
.avatar-preview-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: #f8fafc;
  border: 2px dashed var(--border);
  border-radius: 12px;
  min-height: 200px;
  max-width: 300px;
}

.avatar-preview-box img,
.avatar-preview-box #avatar-atual {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.avatar-placeholder {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 800;
  border: 4px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.avatar-upload-area {
  margin-top: 16px;
}

.avatar-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: #f8fafc;
  transition: all .15s;
  text-align: center;
  max-width: 300px;
}

.avatar-upload-label:hover {
  background: #eff6ff;
  border-color: var(--primary);
}

.avatar-upload-label input[type="file"] {
  display: none;
}

.avatar-upload-icon {
  font-size: 36px;
  line-height: 1;
}

.avatar-upload-label strong {
  font-size: 15px;
  color: var(--text);
}

.avatar-preview-new {
  margin-top: 20px;
}

/* Responsivo */
@media (max-width: 600px) {
  .user-name {
    max-width: 80px;
    font-size: 13px;
  }

  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .avatar-preview-box,
  .avatar-preview-box img,
  .avatar-preview-box #avatar-atual,
  .avatar-placeholder {
    max-width: 100%;
    width: 140px;
    height: 140px;
  }
}
/* =========================================================
   Página de Links — Empresa
   ========================================================= */

.link-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.link-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #f8fafc, #eff6ff);
  border-bottom: 1px solid var(--border);
}

.link-card-icon {
  font-size: 36px;
  line-height: 1;
  flex-shrink: 0;
}

.link-card-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--text);
}

.link-card-header p {
  margin: 0;
  font-size: 13px;
}

.link-card-body {
  padding: 24px;
}

/* Grupo de input + botão */
.link-input-group {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.link-input-group input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: monospace;
  background: #f8fafc;
  color: var(--primary);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-input-group input[type="text"]:focus {
  outline: 2px solid var(--primary-light);
  border-color: var(--primary);
  background: #fff;
}

.link-input-group .btn {
  flex-shrink: 0;
  min-width: 110px;
}

/* Ações rápidas */
.link-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.link-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* QR Code */
.link-qr {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.link-qr img {
  display: block;
  margin: 12px auto;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  border: 1px solid var(--border);
  max-width: 100%;
  height: auto;
}

.link-qr .muted {
  font-size: 12px;
}

/* Responsivo */
@media (max-width: 700px) {
  .link-card-header {
    padding: 16px 18px;
    gap: 12px;
  }

  .link-card-icon {
    font-size: 28px;
  }

  .link-card-header h2 {
    font-size: 16px;
  }

  .link-card-body {
    padding: 18px;
  }

  .link-input-group {
    flex-direction: column;
  }

  .link-input-group input[type="text"] {
    font-size: 11px;
    width: 100%;
  }

  .link-input-group .btn {
    width: 100%;
    min-width: 0;
  }

  .link-actions {
    flex-direction: column;
  }

  .link-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

.whatsapp-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: #25d366;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37,211,102,.4);
  z-index: 999;
  transition: all .2s;
}
.whatsapp-float:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37,211,102,.6);
  text-decoration: none;
}
.whatsapp-float svg {
  width: 32px;
  height: 32px;
}

.btn-whatsapp {
  background: #25D366;
  color: #fff;
  border: 1px solid #1eb257;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(37, 211, 102, .25);
  transition: filter .15s, transform .12s;
}
.btn-whatsapp:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, .4);
}
.btn-whatsapp:active {
  transform: translateY(0);
}