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

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F8FAFC;
  --surface:     #FFFFFF;
  --surface2:    #F1F5F9;
  --surface3:    #E2E8F0;
  --border:      #E2E8F0;
  --border2:     #CBD5E1;
  --text:        #020617; /* Slate 950 */
  --text2:       #1E293B; /* Slate 800 */
  --text3:       #475569; /* Slate 600 */
  --accent:      #F97316;
  --accent-dim:  rgba(249,115,22,0.12);
  --green:       #10B981;
  --green-dim:   rgba(16,185,129,0.1);
  --amber:       #F59E0B;
  --amber-dim:   rgba(245,158,11,0.1);
  --red:         #EF4444;
  --red-dim:     rgba(239,68,68,0.1);
  --blue:        #3B82F6;
  --blue-dim:    rgba(59,130,246,0.1);
  --sidebar-w-expanded: 240px;
  --sidebar-w-collapsed: 72px;
  --sidebar-w:   var(--sidebar-w-expanded);
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 8px 32px rgba(15,23,42,0.06);
  --transition:  0.2s cubic-bezier(0.4,0,0.2,1);
}

html { font-size: 14px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Layout ──────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
}

.sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.sidebar-tenant-chip {
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}
.sidebar-brand img {
  height: 28px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}
.sidebar-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover {
  background: var(--surface2);
  color: var(--text2);
}
.sidebar-toggle ion-icon { font-size: 20px; transition: transform var(--transition); }
.sidebar-logo-text { display: none; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon { font-size: 17px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

/* ── Main Content ─────────────────────────────────────────── */
/* Menu fixed não ocupa fluxo: reservar espaço no body evita sobreposição (ex.: flex + filhos largos). */
body:has(> aside.sidebar) {
  padding-left: var(--sidebar-w);
  transition: padding-left var(--transition);
}
body:has(> aside.sidebar) .main-content {
  margin-left: 0;
}
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--transition);
}

/* Forms Builder — gaveta "Meus formulários": não cobrir o menu lateral fixo (alinhado ao conteúdo principal). */
#forms-list-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: var(--sidebar-w);
  z-index: 99999;
  justify-content: flex-start;
  align-items: stretch;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  transition: left var(--transition);
}

/* ── Top Bar ─────────────────────────────────────────────── */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar--with-chrome {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.07), 0 8px 24px rgba(15, 23, 42, 0.04);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.topbar-title { font-size: 15px; font-weight: 800; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Barra superior global (idioma + conta) — injetada por sidebar.js */
.brspark-app-topbar.topbar-actions {
  gap: 12px;
  align-items: center;
}

/* Ícone de chat global (sidebar.js) */
.topbar-chat-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.topbar-chat-link:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}
.topbar-chat-ic-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.topbar-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  box-sizing: border-box;
}
.topbar-chat-badge[hidden] {
  display: none !important;
}

/* Página Chat (chat.html) */
.admin-chat-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 0;
  min-height: calc(100vh - 200px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
@media (max-width: 960px) {
  .admin-chat-layout {
    grid-template-columns: 1fr;
  }
  .admin-chat-layout.chat-room-open .admin-chat-col-list {
    display: none;
  }
  .admin-chat-layout:not(.chat-room-open) .admin-chat-col-thread {
    display: none;
  }
}
.admin-chat-col-list {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: calc(100vh - 220px);
  background: var(--surface2);
}
.admin-chat-col-thread {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: calc(100vh - 220px);
  background: var(--surface);
}
.admin-chat-list-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.admin-chat-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.admin-chat-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px;
  margin-top: 10px;
  padding: 0 12px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.admin-chat-search-icon {
  display: inline-flex;
  align-items: center;
  color: var(--text3);
  font-size: 18px;
}
.admin-chat-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.admin-chat-search-input::placeholder {
  color: var(--text3);
}
.admin-chat-filter-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text3);
}
.admin-chat-filter-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.admin-chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.admin-chat-room-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.admin-chat-room-row:hover {
  background: var(--surface2);
}
.admin-chat-room-row.is-arch-hint {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.admin-chat-av {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  overflow: hidden;
}
.admin-chat-av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.admin-chat-room-meta {
  flex: 1;
  min-width: 0;
}
.admin-chat-room-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.admin-chat-room-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-chat-room-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  flex-shrink: 0;
}
.admin-chat-room-prev {
  font-size: 13px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.admin-chat-unread-pill {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-chat-state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text3);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-chat-state-pill.is-pending {
  background: var(--status-warn-bg, #fffbeb);
  border-color: #f59e0b33;
  color: #92400e;
}
.admin-chat-state-pill.is-waiting {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.admin-chat-state-pill.is-resolved {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}
.admin-chat-state-pill.is-archived {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text3);
}
.admin-chat-section-title {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 900;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.admin-chat-thread-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.admin-chat-thread-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 40%);
}
.admin-chat-bubble-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 85%;
}
.admin-chat-bubble-row.is-mine {
  align-self: flex-end;
  align-items: flex-end;
}
.admin-chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}
.admin-chat-bubble-row.is-mine .admin-chat-bubble {
  background: #e0f2fe;
  border-color: #bae6fd;
}
.admin-chat-bubble-meta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  font-weight: 600;
}
.admin-chat-compose {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
}
.admin-chat-compose-locked {
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--status-warn-bg, #fffbeb);
  border: 1px solid var(--border);
}
.admin-chat-compose-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.admin-chat-compose textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 14px;
}
.admin-chat-pending {
  margin: 8px 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #fffbeb;
}
.admin-chat-pending-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-chat-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.admin-chat-modal-overlay[hidden] {
  display: none !important;
}
.admin-chat-modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  border: 1px solid var(--border);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}
.admin-chat-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.admin-chat-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}
.admin-chat-modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.admin-chat-modal-tabs button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  color: var(--text3);
}
.admin-chat-modal-tabs button.is-active {
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  color: var(--accent);
}
.admin-chat-user-results {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  max-height: 280px;
  overflow-y: auto;
}
.admin-chat-user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.admin-chat-user-row:last-child {
  border-bottom: none;
}
.admin-chat-user-main {
  flex: 1;
  min-width: 0;
}
.admin-chat-user-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.admin-chat-user-name {
  font-size: 13px;
  color: var(--text);
}
.admin-chat-user-role {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
}
.admin-chat-user-meta {
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.admin-chat-user-empty {
  padding: 14px 12px;
  color: var(--text3);
  font-size: 13px;
  font-weight: 600;
}
.topbar-locale-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.topbar-locale-icon {
  display: flex;
  align-items: center;
  color: var(--accent);
  font-size: 20px;
}
.topbar-locale-select {
  min-width: 72px;
  max-width: 110px;
  padding: 6px 10px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
}
.topbar-user-details {
  position: relative;
}
.topbar-user-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.topbar-user-details > summary::-webkit-details-marker {
  display: none;
}
.topbar-user-details > summary::marker {
  content: '';
}
.topbar-user-details[open] > summary {
  background: var(--surface2);
}
.topbar-user-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.topbar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #fb923c);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.topbar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 160px;
  line-height: 1.2;
}
.topbar-user-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user-email {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: 200;
  min-width: 168px;
}
.topbar-user-dropdown .btn {
  width: 100%;
  justify-content: center;
}
@media (max-width: 640px) {
  .topbar-user-meta {
    display: none;
  }
}

/* ── Page Body ───────────────────────────────────────────── */
.page-body {
  padding: 28px 28px 60px;
  flex: 1;
}

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--border2); box-shadow: var(--shadow); }
a.stat-card.stat-card--link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
a.stat-card.stat-card--link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent-color, var(--accent));
}
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
  color: var(--accent);
}
.stat-value { font-size: 26px; font-weight: 900; color: var(--text); letter-spacing: -1px; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-delta {
  font-size: 10px;
  font-weight: 700;
  margin-top: 8px;
  display: flex; align-items: center; gap: 4px;
}
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta.neutral { color: var(--text3); }

/* ── Cards / Panels ──────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title { font-size: 13px; font-weight: 700; color: var(--text); }
.panel-body { padding: 20px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text2);
  vertical-align: middle;
}
tbody td.bold { font-weight: 700; color: var(--text); }
tbody td.mono { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.badge-green   { background: var(--green-dim); color: var(--green); }
.badge-red     { background: var(--red-dim);   color: var(--red); }
.badge-danger  { background: var(--red-dim);   color: var(--red); }
.badge-amber   { background: var(--amber-dim); color: var(--amber); }
.badge-blue    { background: var(--blue-dim);  color: var(--blue); }
.badge-accent  { background: var(--accent-dim); color: var(--accent); }
.badge-gray    { background: var(--surface3); color: var(--text2); }
.badge-purple  { background: rgba(139,92,246,0.1); color: #8B5CF6; }
.badge-success { background: var(--green-dim); color: var(--green); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(249,115,22,0.2);
}
.btn-primary:hover { background: #EA580C; box-shadow: 0 4px 16px rgba(249,115,22,0.3); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-outline {
  background: var(--surface);
  color: var(--text2);
  border: 1px solid var(--border2);
  box-shadow: none;
}
.btn-outline:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--text3);
}
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

/* ── Form Controls ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 700; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249,115,22,0.15); }
.form-control::placeholder { color: var(--text3); }

/* ── Toggle / Switch ─────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 11px;
  transition: all 0.2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text3);
  border-radius: 50%;
  transition: all 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track::before { transform: translateX(18px); background: #fff; }
.toggle-label { font-size: 12px; font-weight: 600; color: var(--text); }
.toggle-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Search ──────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap .search-icon { position: absolute; left: 12px; font-size: 14px; color: var(--text3); }
.search-wrap input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 36px;
  color: var(--text);
  font-size: 12px;
  outline: none;
  width: 220px;
  transition: all var(--transition);
}
.search-wrap input:focus { border-color: var(--accent); width: 280px; }
.search-wrap input::placeholder { color: var(--text3); }

/* ── Listagens admin (padrão “data page”) ───────────────── */
.topbar--data {
  min-height: 48px;
  height: auto;
  padding-top: 10px;
  padding-bottom: 10px;
  align-items: center;
}
.topbar-breadcrumb {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  flex: 1;
  min-width: 0;
}
.topbar-breadcrumb-sep {
  margin: 0 6px;
  opacity: 0.55;
  font-weight: 500;
}

.page-hero {
  margin-bottom: 28px;
  max-width: 720px;
}
.page-hero-title {
  font-size: clamp(1.5rem, 2.2vw, 1.85rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--color-slate, #0f172a);
  line-height: 1.15;
  margin-bottom: 10px;
}
.page-hero-sub {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text3);
  font-weight: 500;
}

.data-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  margin-bottom: 24px;
}

.data-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 20px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
}
.data-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 18px;
  flex: 1;
  min-width: 0;
}
.data-toolbar-search-filters {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.data-toolbar-search-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.users-filters-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.data-toolbar-filters-panel {
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.22s ease;
  max-height: 2000px;
  opacity: 1;
}
.data-toolbar-filters-panel.is-collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .data-toolbar-filters-panel {
    transition: none;
  }
}
.data-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
}
.data-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.search-wrap--toolbar input {
  width: min(100%, 320px);
  min-width: 200px;
  border-radius: 999px;
  padding-left: 40px;
  padding-right: 16px;
}
.search-wrap--toolbar input:focus {
  width: min(100%, 380px);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.filter-field-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text3);
}
.filter-field-label ion-icon {
  font-size: 14px;
  opacity: 0.85;
}
.filter-field-control {
  width: auto;
  min-width: 160px;
  max-width: 220px;
  padding: 8px 12px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--surface);
}
.filter-field--check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  user-select: none;
}
.filter-field--check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.filter-field--check .filter-field-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 0;
}
.filter-chips[hidden] {
  display: none !important;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--color-status-info-bg, var(--blue-dim));
  color: var(--color-status-info-fg, var(--blue));
  border: 1px solid var(--color-status-info-border, transparent);
}
.filter-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 50%;
  color: inherit;
  opacity: 0.75;
  cursor: pointer;
}
.filter-chip button:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.35);
}
.users-context-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 14px;
  padding: 0 20px;
}
.users-context-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.users-context-card__eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.users-context-card__title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}
.users-context-card__meta {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
  margin-top: 6px;
}
.users-context-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.users-context-chip {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
}
.ul-columns-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 0 20px 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: 12px;
  color: var(--text2);
}
.ul-columns-bar__title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ul-columns-bar__title span {
  font-weight: 800;
  color: var(--text);
}
.ul-columns-bar__title small {
  color: var(--text3);
  line-height: 1.4;
}
.ul-columns-bar__options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.ul-columns-bar__options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.data-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 0;
}
.data-table-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text2);
}

.table-data thead th {
  background: var(--color-slate, #0f172a);
  color: #f8fafc;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  border-bottom: none;
  padding: 12px 16px;
}
.table-data thead th:first-child {
  border-radius: 0;
}
.table-data tbody td {
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  transition: background-color var(--transition), border-color var(--transition);
}
.table-data tbody tr:nth-child(even) td {
  background: rgba(148, 163, 184, 0.04);
}
.table-data tbody tr:hover td {
  background: rgba(59, 130, 246, 0.06);
}
.table-data tbody tr:has(.ul-row-sel:checked) td {
  background: rgba(59, 130, 246, 0.1);
  border-bottom-color: rgba(59, 130, 246, 0.18);
}
.table-data td.table-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.table-data td.table-subtle {
  font-size: 11px;
  color: var(--text3);
}
.table-data td.table-actions {
  white-space: nowrap;
}
#users-table tbody td {
  padding-top: 14px;
  padding-bottom: 14px;
}
#users-table tbody td:first-child,
#users-table tbody td:last-child {
  white-space: nowrap;
}

.text-right {
  text-align: right;
}
th.text-right {
  text-align: right;
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.person-cell-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.person-name {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.person-email {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.list-cell-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.list-cell-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}
.list-cell-sub {
  font-size: 10px;
  color: var(--text3);
  line-height: 1.35;
  word-break: break-word;
}
.list-cell-metric {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.user-avatar-ph {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: var(--color-status-info-fg, var(--blue));
  background: var(--color-status-info-bg, var(--blue-dim));
  border: 1px solid var(--color-status-info-border, var(--border));
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}
.ul-inline-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.ul-inline-card--good {
  border-color: rgba(16, 185, 129, 0.24);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.05) 0%, var(--surface) 80%);
}
.ul-inline-card--warn {
  border-color: rgba(245, 158, 11, 0.24);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.05) 0%, var(--surface) 80%);
}
.ul-inline-card--danger {
  border-color: rgba(239, 68, 68, 0.22);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.05) 0%, var(--surface) 80%);
}
.ul-inline-card__eyebrow {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text3);
}
.ul-inline-card__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}
.ul-inline-card__sub {
  font-size: 10px;
  color: var(--text3);
  line-height: 1.35;
  word-break: break-word;
}
.ul-inline-card__metric {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
}
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text3);
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.icon-action:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}
.icon-action ion-icon {
  font-size: 18px;
}
.icon-action--danger:hover {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.25);
  background: var(--red-dim);
}
.icon-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pagination-pro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.pagination-meta {
  font-size: 12px;
  color: var(--text3);
  font-weight: 600;
}
.pagination-meta strong {
  color: var(--text2);
  font-weight: 800;
}
.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.pagination-page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
}
.pagination-page-size select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.pagination-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.pagination-btn:hover:not(:disabled) {
  background: var(--surface2);
  border-color: var(--border2);
}
.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination-btn--active {
  background: var(--color-slate, #0f172a);
  color: #fff;
  border-color: var(--color-slate, #0f172a);
}

.table-skeleton {
  padding: 20px 20px 28px;
}
.table-skeleton-row {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface3) 25%, var(--surface2) 50%, var(--surface3) 75%);
  background-size: 200% 100%;
  animation: sk 1.2s ease-in-out infinite;
  margin-bottom: 14px;
}
.table-skeleton-row:nth-child(2) {
  width: 85%;
}
.table-skeleton-row:nth-child(3) {
  width: 70%;
}
.table-skeleton-row:nth-child(4) {
  width: 92%;
}
.table-skeleton-row:nth-child(5) {
  width: 60%;
}
@keyframes sk {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.empty-state-pro {
  text-align: center;
  padding: 48px 24px 40px;
  color: var(--text3);
}
.empty-state-pro ion-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.35;
}
.empty-state-pro-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text2);
  margin-bottom: 6px;
}
.empty-state-pro-sub {
  font-size: 13px;
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.45;
}

@media (max-width: 1280px) {
  .col-hide-wide {
    display: none;
  }
}
@media (max-width: 1024px) {
  .col-hide-md {
    display: none;
  }
}
/* Dashboard: espaço entre faixa de KPIs e os dois cartões */
.dashboard-panels-grid {
  margin-top: 4px;
}
.dashboard-tenants {
  margin-top: 20px;
}

/* Estoque abaixo do mínimo — resumo acima da tabela */
.sc-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  max-width: 640px;
  margin-bottom: 22px;
}

@media (max-width: 768px) {
  .data-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .data-toolbar-actions {
    justify-content: stretch;
  }
  .data-toolbar-actions .btn {
    flex: 1;
    justify-content: center;
  }
  .search-wrap--toolbar input {
    width: 100%;
  }
  .search-wrap--toolbar input:focus {
    width: 100%;
  }
  #users-table {
    min-width: 980px;
  }
  .person-cell {
    gap: 10px;
  }
  .person-name {
    max-width: 180px;
  }
  .person-email {
    max-width: 200px;
  }
  .list-cell-title {
    font-size: 11px;
  }
  .list-cell-sub,
  .list-cell-metric {
    font-size: 9px;
  }
  .row-actions {
    gap: 2px;
  }
  .icon-action {
    width: 32px;
    height: 32px;
  }
  .pagination-pro {
    padding-inline: 14px;
  }
}

/* ── Alert Rows ──────────────────────────────────────────── */
.alert-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.alert-row:last-child { border-bottom: none; }
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.alert-row-content { flex: 1; }
.alert-row-title { font-size: 12px; font-weight: 700; color: var(--text); }
.alert-row-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.alert-row-time { font-size: 10px; color: var(--text3); white-space: nowrap; }

/* ── Activity Feed ───────────────────────────────────────── */
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-text { font-size: 12px; color: var(--text2); line-height: 1.4; }
.activity-text strong { color: var(--text); font-weight: 700; }
.activity-time { font-size: 10px; color: var(--text3); margin-top: 3px; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}
/* Com `opacity:0` o painel continua com `display:flex`; filhos herdavam hits e bloqueavam cliques no fundo. */
.modal-overlay:not(.open):not([style*='display:flex']):not([style*='display: flex']) .modal {
  pointer-events: none;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  width: 480px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-lg { width: 840px; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 800; color: var(--text); }
.modal-close { color: var(--text3); font-size: 18px; cursor: pointer; transition: color var(--transition); border: none; background: none; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.tenant-branding-modal {
  width: min(760px, calc(100vw - 32px));
  max-width: min(760px, calc(100vw - 32px));
}
.tenant-branding-modal__body {
  max-height: min(85vh, 720px);
  overflow-y: auto;
  overflow-x: hidden;
}
.tenant-branding-modal__grid {
  gap: 16px;
}
.tenant-branding-modal__field {
  min-width: 0;
}
.tenant-branding-modal__field .form-control {
  min-width: 0;
}
.tenant-branding-modal__color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tenant-branding-modal__color-text {
  flex: 1 1 auto;
}
.tenant-branding-modal__color-picker {
  width: 52px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(241,245,249,0.95));
  cursor: pointer;
  flex: 0 0 auto;
  overflow: hidden;
}
.tenant-branding-modal__color-picker::-webkit-color-swatch-wrapper {
  padding: 4px;
}
.tenant-branding-modal__color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 9px;
}
.tenant-branding-modal__color-picker::-moz-color-swatch {
  border: none;
  border-radius: 9px;
}
.tenant-branding-modal__upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.tenant-branding-modal__file-input {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 240px;
}
.tenant-branding-modal__preview-shell {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,.015);
}
.tenant-branding-modal__preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

/* ── Login Page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.login-bg-glow {
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249,115,22,0.1) 0%, transparent 70%);
  top: -200px; left: -200px;
  pointer-events: none;
}
.login-bg-glow2 {
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249,115,22,0.06) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 400px;
  max-width: calc(100vw - 32px);
  padding: 40px;
  box-shadow: 0 12px 48px rgba(15,23,42,0.1);
  position: relative;
  z-index: 1;
}
.login-card-wide {
  width: min(440px, calc(100vw - 32px));
}
.login-label-hint { font-weight: 500; color: var(--text3); font-size: 11px; }
.login-field-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 6px;
  line-height: 1.4;
}
.login-field-hint code { font-size: 10px; }
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo img {
  height: 48px;
  width: auto;
}
.login-logo-text { margin-top: 4px; }
.login-logo-text h1 { display: none; }
.login-logo-text p { font-size: 10px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.8; }
.login-title { font-size: 22px; font-weight: 900; color: var(--text); letter-spacing: -0.5px; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text3); margin-bottom: 28px; }

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #8B5CF6);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(249,115,22,0.3);
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(249,115,22,0.4); }
.login-btn:active { transform: translateY(0); }
.login-error {
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }
.login-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text3);
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.login-hint code { color: var(--accent); font-weight: 700; background: var(--accent-dim); padding: 2px 6px; border-radius: 4px; }

/* ── Feature Flag Items ──────────────────────────────────── */
.flag-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.flag-item:last-child { border-bottom: none; }
.flag-icon { font-size: 22px; width: 36px; text-align: center; flex-shrink: 0; }
.flag-info { flex: 1; }
.flag-name { font-size: 13px; font-weight: 700; color: var(--text); }
.flag-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── 2-col grid ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Divider ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-title { font-size: 14px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.empty-state-sub { font-size: 12px; }

/* ── Sidebar recolhível (desktop) ───────────────────────── */
@media (min-width: 769px) {
  body.sidebar-collapsed {
    --sidebar-w: var(--sidebar-w-collapsed);
  }
  body.sidebar-collapsed .sidebar-toggle ion-icon {
    transform: scaleX(-1);
  }
  body.sidebar-collapsed .sidebar-header {
    padding: 12px 8px;
    gap: 8px;
  }
  body.sidebar-collapsed .sidebar-header-row {
    flex-direction: column;
  }
  body.sidebar-collapsed .sidebar-tenant-chip {
    display: none;
  }
  body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
  }
  body.sidebar-collapsed .sidebar-brand img {
    height: 26px;
    max-width: 44px;
    object-position: center;
  }
  body.sidebar-collapsed .nav-section-label {
    display: none;
  }
  body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 9px 8px;
    gap: 0;
  }
  body.sidebar-collapsed .nav-item > span:not(.nav-badge) {
    display: none;
  }
  body.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    margin-left: 0;
    min-width: 16px;
    padding: 1px 4px;
    font-size: 8px;
  }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  body:has(> aside.sidebar) {
    padding-left: 0;
  }
  #forms-list-modal {
    left: 0;
  }
  .main-content { margin-left: 0; }
  body.sidebar-collapsed {
    --sidebar-w: var(--sidebar-w-expanded);
  }
  .sidebar-toggle { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tenant-branding-modal {
    width: min(760px, calc(100vw - 16px));
    max-width: min(760px, calc(100vw - 16px));
  }
  .tenant-branding-modal__body {
    padding-left: 16px;
    padding-right: 16px;
  }
  .tenant-branding-modal__color-row {
    align-items: stretch;
  }
  .tenant-branding-modal__color-picker {
    width: 48px;
    min-width: 48px;
  }
  .tenant-branding-modal .modal-footer {
    padding-left: 16px;
    padding-right: 16px;
    flex-wrap: wrap;
  }
  .tenant-branding-modal__preview-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Ficha de edição de usuário (altura fixa + scroll interno) ── */
html.ue-edit-html,
html.ue-edit-html body {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
html.ue-edit-html #page-root.admin-layout {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}
html.ue-edit-html .main-content.ue-edit-layout {
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
html.ue-edit-html .main-content.ue-edit-layout > .topbar {
  flex-shrink: 0;
}
html.ue-edit-html .main-content.ue-edit-layout > .ue-page-toolbar.data-toolbar {
  flex-shrink: 0;
  margin-bottom: 0;
}
.ue-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ue-sticky-tools {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
  padding: 14px 28px 16px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.ue-sticky-tools .hint-box {
  margin-bottom: 12px;
}
.ue-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: none;
}
.ue-nav-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ue-nav-group__label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
  margin-right: 2px;
}
.ue-nav a {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.ue-nav a:hover {
  color: var(--accent);
  border-color: var(--border2);
  background: var(--surface2);
}
.ue-nav a.is-active {
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.24);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.08);
}
.ue-scroll-inner {
  padding: 20px 28px 60px;
}
.ue-section {
  scroll-margin-top: 11rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.ue-section.is-active {
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.18), 0 12px 28px rgba(59, 130, 246, 0.05);
  border-color: rgba(59, 130, 246, 0.24);
}
.ue-section[data-ue-default-collapsed='true'] .data-shell-body {
  display: none;
}
.ue-section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.ue-section-toggle:hover {
  background: var(--surface);
  border-color: var(--border2);
  color: var(--text);
}
.ue-section-toggle ion-icon {
  font-size: 14px;
}
.ue-section[data-ue-collapsed='false'] .data-shell-body {
  display: block;
}
.ue-section[data-ue-collapsed='true'] .data-shell-body {
  display: none;
}
.ue-section .panel-header {
  gap: 12px;
}
.ue-section-summary {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.4;
  margin-left: auto;
  text-align: right;
}
.page-hero--edit {
  margin-bottom: 22px;
  max-width: 720px;
}
.data-shell-body {
  padding: 18px 20px 22px;
}
.ue-section-intro {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
  margin: 0 0 12px;
}
.ue-task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.ue-task-grid--compact {
  margin-top: 14px;
}
.ue-task-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.ue-task-card--wide {
  grid-column: 1 / -1;
}
.ue-task-card__title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
  margin: 0 0 8px;
}
.ue-task-card__hint {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
  margin: 0 0 12px;
}
.ue-inline-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.ue-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.ue-inline-status {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
}
.ue-section-spaced {
  margin-top: 20px;
}
.doc-table.table-data tbody td {
  font-size: 12px;
  vertical-align: top;
}
.hint-box {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 0;
}
.ue-coverage-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ue-coverage-actions {
  margin-bottom: 0;
}
.ue-coverage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 14px;
  align-items: start;
}
.ue-coverage-map-card {
  min-height: 100%;
}
.ue-coverage-map {
  width: 100%;
  min-height: 360px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.ue-coverage-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ue-coverage-summary__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.ue-coverage-summary__item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ue-coverage-summary__item strong {
  font-size: 15px;
  color: var(--text);
}
.ue-coverage-summary__label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ue-coverage-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ue-coverage-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
}
.ue-coverage-empty {
  font-size: 12px;
  color: var(--text3);
  font-weight: 600;
}
.ue-coverage-coords-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 12px;
}
.ue-coverage-coords-card__label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ue-coverage-coords-card__value {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}
.ue-coverage-modal {
  width: min(1100px, calc(100vw - 32px));
}
.ue-coverage-modal .modal-body {
  padding-top: 16px;
}
.ue-coverage-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.ue-coverage-modal-search {
  flex: 1;
}
.ue-coverage-modal-search input {
  width: 100%;
  max-width: none;
}
.ue-coverage-modal-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 14px;
}
.ue-coverage-modal-list {
  max-height: 460px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  padding: 6px;
}
.ue-coverage-list-row {
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.ue-coverage-list-row:hover {
  background: var(--surface);
  border-color: var(--border);
}
.ue-coverage-list-row.is-active {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.ue-coverage-list-row--disabled {
  opacity: 0.6;
}
.ue-coverage-list-row__title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.ue-coverage-list-row__meta {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.4;
}
.ue-coverage-modal-map {
  min-height: 460px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
@media (max-width: 900px) {
  .ue-nav-group {
    width: 100%;
  }
  .ue-section-summary {
    display: none;
  }
  .ue-task-grid {
    grid-template-columns: 1fr;
  }
  .ue-coverage-layout,
  .ue-coverage-modal-layout {
    grid-template-columns: 1fr;
  }
  .ue-coverage-summary__grid {
    grid-template-columns: 1fr;
  }
  .ue-coverage-modal-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .ue-coverage-map,
  .ue-coverage-modal-map {
    min-height: 300px;
  }
}

/* Ficha usuário — CLT/PJ (Brasil): rádios com aparência de botão */
.wt-br-regime-seg .wt-br-lbl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.wt-br-regime-seg .wt-br-lbl input[type='radio'] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
/* Estado seleccionado só em CSS — evita reflows em JS a cada clique */
.wt-br-regime-seg .wt-br-lbl:has(input[type='radio']:checked) {
  box-shadow: 0 0 0 2px var(--accent);
  border-color: var(--accent);
}
.face-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.face-card {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 3 / 4;
  background: var(--surface2);
}
.face-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.face-card .face-rm {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}
.face-card--primary {
  box-shadow: 0 0 0 2px var(--accent);
}
.face-card-ribbon {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background: linear-gradient(transparent, rgba(15, 23, 42, 0.85));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 22px 6px 6px;
  text-align: center;
  line-height: 1.25;
}
.face-card-protected {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  font-size: 10px;
  font-weight: 600;
  color: var(--text2);
  background: var(--surface);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-width: 118px;
  text-align: center;
  line-height: 1.2;
}
.ue-compreface-sync {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border2);
  background: linear-gradient(165deg, var(--surface2) 0%, var(--surface) 100%);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}
.ue-compreface-sync__row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}
.ue-compreface-sync__icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ue-compreface-sync__icon ion-icon {
  font-size: 24px;
}
.ue-compreface-sync__text {
  flex: 1;
  min-width: 200px;
}
.ue-compreface-sync__text strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.ue-compreface-sync__text span.desc {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
}
.ue-compreface-sync__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.ue-compreface-sync__actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#compreface-sync-status {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
  min-width: 160px;
}
#compreface-sync-status.cf-sync--idle {
  color: var(--text3);
  font-weight: 500;
}
#compreface-sync-status.cf-sync--loading {
  color: var(--accent);
}
#compreface-sync-status.cf-sync--ok {
  color: var(--green);
}
#compreface-sync-status.cf-sync--err {
  color: var(--red);
}
#compreface-admin-status {
  width: 100%;
  margin-top: 12px;
}
.cf-admin-badge {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.cf-admin-badge strong {
  font-weight: 800;
}
.cf-admin--muted {
  background: var(--surface2);
  color: var(--text3);
}
.cf-admin--ok {
  background: var(--color-status-success-bg, #ecfdf5);
  border-color: var(--color-status-success-border, #6ee7b7);
  color: var(--color-status-success-fg, #14532d);
}
.cf-admin--pending {
  background: var(--color-status-warning-bg, #fffbeb);
  border-color: var(--color-status-warning-border, #fcd34d);
  color: var(--color-status-warning-fg, #92400e);
}
.cf-admin--err {
  background: var(--color-status-danger-bg, #fef2f2);
  border-color: var(--color-status-danger-border, #fecaca);
  color: var(--color-status-danger-fg, #991b1b);
}

/* Estado fatal na ficha de usuário (substitui o layout de formulário) */
html.ue-edit-error-html,
html.ue-edit-error-html body {
  height: auto;
  min-height: 100%;
  max-height: none;
  overflow: auto;
}
html.ue-edit-error-html #page-root.admin-layout {
  height: auto;
  min-height: 100vh;
  max-height: none;
  overflow: visible;
}
.ue-edit-error-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.ue-edit-error-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 48px;
}
.ue-edit-error-card {
  width: 100%;
  max-width: 520px;
}
.ue-edit-error-detail {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text2);
  text-align: left;
  line-height: 1.45;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Micro animations ────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulse { animation: pulse 2s infinite; }

/* Ficha de utilizador — resumo, alterações não guardadas, dropdown, documentos */
.ue-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ue-workspace-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}
.ue-workspace-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-height: 132px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.ue-workspace-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  border-color: var(--border2);
}
.ue-workspace-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.ue-workspace-card__eyebrow {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text3);
}
.ue-workspace-card__title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}
.ue-workspace-card__meta {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
}
.ue-workspace-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ue-workspace-card__chip {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
}
.ue-workspace-card__cta {
  margin-top: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}
.ue-workspace-tone--good {
  border-color: rgba(16, 185, 129, 0.28);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.05) 0%, var(--surface) 68%);
}
.ue-workspace-tone--warn {
  border-color: rgba(245, 158, 11, 0.28);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.06) 0%, var(--surface) 68%);
}
.ue-workspace-tone--info {
  border-color: rgba(59, 130, 246, 0.24);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, var(--surface) 68%);
}
.ue-workspace-tone--muted {
  border-color: var(--border);
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 68%);
}
.ue-tech-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.ue-tech-summary__card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.ue-tech-summary__card--good {
  border-color: rgba(16, 185, 129, 0.28);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.06) 0%, var(--surface) 68%);
}
.ue-tech-summary__card--warn {
  border-color: rgba(245, 158, 11, 0.28);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.06) 0%, var(--surface) 68%);
}
.ue-tech-summary__card--danger {
  border-color: rgba(239, 68, 68, 0.24);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.06) 0%, var(--surface) 68%);
}
.ue-tech-summary__card--muted {
  background: linear-gradient(180deg, var(--surface2) 0%, var(--surface) 68%);
}
.ue-tech-summary__eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.ue-tech-summary__title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}
.ue-tech-summary__meta {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.45;
  margin-top: 6px;
}
.ue-tech-summary__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.ue-tech-summary__chip {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
}
.ue-sum-chip {
  font-size: 11px;
  color: var(--text2);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  line-height: 1.35;
}
.ue-unsaved-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.35);
  margin-right: 8px;
}
.ue-toolbar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.ue-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ue-locale-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
}
.ue-nav-arrows {
  display: inline-flex;
  gap: 4px;
}
.ue-nav-arrows a[disabled] {
  pointer-events: none;
  opacity: 0.35;
}
@media (max-width: 1080px) {
  .users-context-bar {
    grid-template-columns: 1fr;
  }
  .ue-workspace-bar {
    grid-template-columns: 1fr;
  }
  .ue-tech-summary {
    grid-template-columns: 1fr;
  }
}
.ue-dropdown-wrap {
  position: relative;
}
.ue-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 80;
  padding: 6px;
}
.ue-dropdown__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--text2);
  background: transparent;
  border: none;
  cursor: pointer;
}
.ue-dropdown__item:hover {
  background: var(--surface2);
}
.ue-dropdown__item--link {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
}
.ue-dropdown__sep {
  margin: 6px 4px;
  border: none;
  border-top: 1px solid var(--border);
}
.ue-dropdown__item--danger {
  color: var(--red);
  font-weight: 600;
}
.ue-dropdown__item--danger:hover {
  background: var(--red-dim);
  color: var(--red);
}
.ue-doc-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}
.ue-doc-badge--ok {
  background: var(--green-dim);
  color: var(--green);
}
.ue-doc-badge--warn {
  background: var(--amber-dim);
  color: var(--amber);
}
.ue-doc-badge--err {
  background: var(--red-dim);
  color: var(--red);
}
.ue-doc-badge--muted {
  background: var(--surface2);
  color: var(--text3);
  font-weight: 500;
}
.ue-docs-table thead {
  display: none;
}
.ue-docs-table tbody,
.ue-docs-table tr,
.ue-docs-table td {
  width: 100%;
}
.ue-docs-table tbody tr[data-doc-id] td {
  padding: 0;
  border: none;
}
.ue-doc-card-cell {
  padding: 0 !important;
  background: transparent;
}
.ue-doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}
.ue-doc-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.ue-doc-card__head-main {
  min-width: 0;
  flex: 1 1 auto;
}
.ue-doc-card__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.ue-doc-card__type {
  min-width: 220px;
  max-width: 320px;
}
.ue-doc-card__remove {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.22);
  background: rgba(239, 68, 68, 0.06);
}
.ue-doc-card__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.ue-doc-card__locs,
.ue-doc-card__notes {
  grid-column: 1 / -1;
}
.ue-doc-card__microcopy {
  font-size: 10px;
  color: var(--text3);
  line-height: 1.4;
  margin-top: 4px;
}
.ue-doc-empty-cell {
  text-align: center;
  color: var(--text3);
  padding: 18px 14px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  background: var(--surface2);
}
.ue-doc-attach-cell .doc-upload-btn {
  width: 100%;
  margin-top: 8px;
}
@media (max-width: 900px) {
  .ue-doc-card__grid {
    grid-template-columns: 1fr;
  }
  .ue-doc-card__type {
    min-width: 0;
    width: 100%;
    max-width: none;
  }
}
.ue-face-progress {
  height: 4px;
  max-width: 220px;
  margin: 8px 0 0;
  border-radius: 4px;
  background: var(--surface3);
  overflow: hidden;
}
.ue-face-progress__bar {
  height: 100%;
  width: 40%;
  border-radius: 4px;
  background: var(--accent);
  animation: ueFaceBar 0.9s ease-in-out infinite alternate;
}
@keyframes ueFaceBar {
  from { transform: translateX(0); opacity: 0.7; }
  to { transform: translateX(120%); opacity: 1; }
}

/* Lista de usuários: colunas opcionais + cabeçalhos ordenáveis */
#users-table:not(.cols-show-id) .ul-col-id {
  display: none;
}
#users-table:not(.cols-show-created) .ul-col-created {
  display: none;
}
#users-table:not(.cols-show-country) .ul-col-country {
  display: none;
}
#users-table:not(.cols-show-emailver) .ul-col-emailver {
  display: none;
}
#users-table .ul-th-sort {
  display: block;
  width: 100%;
  margin: 0;
  padding: 2px 4px;
  font: inherit;
  font-weight: 600;
  color: inherit;
  text-align: inherit;
  border-radius: 6px;
  background: transparent;
}
#users-table .ul-th-sort:hover {
  color: var(--accent);
}
#users-table .ul-th-sort:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Lista de usuários: seleção em massa */
.ul-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
}
.ul-bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
}
.ul-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.ul-bulk-deactivate-btn {
  border-color: var(--red) !important;
  color: var(--red) !important;
}
.ul-bulk-deactivate-btn:hover {
  background: var(--red-dim) !important;
}
#users-table .ul-col-sel {
  width: 40px;
  text-align: center;
  vertical-align: middle;
}
#users-table .ul-col-sel .ul-select-all,
#users-table .ul-col-sel .ul-row-sel {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Impersonação no painel (sidebar) */
.sidebar-impersonation {
  margin: 10px 12px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  font-size: 12px;
  line-height: 1.45;
  color: var(--text2);
}
.sidebar-impersonation__txt {
  margin-bottom: 10px;
}
.sidebar-impersonation__btn {
  width: 100%;
  justify-content: center;
}

/* Ficha de utilizador — só leitura */
.ue-readonly-banner {
  margin: 0 28px 16px;
}
html.ue-readonly-mode .ue-readonly-banner {
  border-color: var(--blue);
  background: var(--blue-dim);
}

textarea.ue-rbac-readonly-field {
  cursor: not-allowed;
  opacity: 0.92;
}
