:root {
  --bg: #F3F3F6;
  --card: #FFFFFF;
  --ink: #15161C;
  --muted: #8B8F98;
  --line: #ECECF0;
  --purple: #6C4CF1;
  --purple-dark: #5A3CE0;
  --purple-soft: #EFEAFE;
  --purple-stripe: #D9CCFB;
  --yellow: #F2E852;
  --green: #22C55E;
  --green-soft: #DEFBE8;
  --red: #EF4A6D;
  --red-soft: #FDE4E9;
  --amber: #F2A93B;
  --amber-soft: #FCEDD6;
  --blue: #4AAEEF;
  --blue-soft: #E2F3FD;
  --orange: #FDBA74;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14.5px;
}

.muted {
  color: var(--muted);
}

/* Sidebar icon rail */
#sidebar {
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0 28px 1.5rem;
  z-index: 100;
}

#sidebar nav {
  flex-shrink: 0;
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
  padding: 10px 8px;
  border-radius: 30px;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 21px;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  margin-bottom: 8px;
  text-decoration: none;
}

.nav-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.nav-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  transition: .15s ease;
  background: transparent;
  position: relative;
  text-decoration: none;
}

.nav-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  margin-left: 12px;
  top: 50%;
  transform: translateY(-50%) scale(0.92);
  background: var(--ink);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 1000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.nav-icon:hover {
  background: var(--purple-soft);
  color: var(--purple);
}

.nav-icon:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) scale(1);
}

.nav-icon.active {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 8px 18px -6px rgba(108, 76, 241, .55);
}

.nav-icon.nav-icon-circ {
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
}

.nav-icon.nav-icon-circ:hover {
  background: var(--purple-soft);
  color: var(--purple);
}

.nav-icon.nav-icon-circ.active {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 8px 18px -6px rgba(108, 76, 241, .55);
}

.avatar-user {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  font-size: 14.5px;
}

.avatar-lg {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 26px;
  flex-shrink: 0;
  position: relative;
}

.avatar-edit-btn {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  border: 3px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
}

/* Main */
#content {
  flex: 1;
  padding: 28px 1.5rem;
  min-width: 0;
}

.topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}

.topline h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0;
}

.topline p {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 13.5px;
  max-width: 460px;
}

.breadcrumb-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 10px;
}

.breadcrumb-link:hover {
  color: var(--purple);
}

.search-pill {
  background: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  color: var(--muted);
  border: 1px solid var(--line);
}

.search-pill input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  font-size: 13.5px;
}

.bell-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: .15s ease;
}

.bell-btn:hover {
  background: var(--bg);
  color: var(--purple);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-size: 15px;
}

.btn-export {
  background: var(--purple);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-export:hover {
  background: var(--purple-dark);
  color: #fff;
}

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 22px;
  border-radius: 999px;
}

.btn-ghost:hover {
  background: var(--bg);
}

.btn-danger-soft {
  background: var(--red-soft);
  color: var(--red);
  border: none;
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 22px;
  border-radius: 999px;
}

.btn-danger-soft:hover {
  background: var(--red);
  color: #fff;
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 22px;
  border: 1px solid var(--line);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.panel-head h5 {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}

.panel-head .sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Forms */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.field .field-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

.form-control,
.form-select {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 13.5px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-soft);
  outline: none;
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

.input-icon-group {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
}

.input-icon-group:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-soft);
}

.input-icon-group i {
  color: var(--muted);
  font-size: 14px;
}

.input-icon-group input {
  border: none;
  outline: none;
  background: transparent;
  flex: 1;
  padding: 11px 10px;
  font-size: 13.5px;
  font-family: inherit;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--line);
  border-radius: 999px;
  transition: .15s ease;
}

.switch .slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}

.switch input:checked+.slider {
  background: var(--green);
}

.switch input:checked+.slider::before {
  transform: translateX(18px);
}

/* Badges / pills */
.pill-status {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.pill-status.ativo {
  background: var(--green-soft);
  color: var(--green);
}

.pill-status.inativo {
  background: var(--red-soft);
  color: var(--red);
}

.pill-status.pendente {
  background: var(--amber-soft);
  color: var(--amber);
}

.role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.role-badge.admin {
  background: var(--purple-soft);
  color: var(--purple);
}

.role-badge.financeiro {
  background: var(--blue-soft);
  color: var(--blue);
}

.role-badge.operacional {
  background: var(--amber-soft);
  color: var(--amber);
}

.role-badge.personalizado {
  background: var(--bg);
  color: var(--ink);
}

/* Users table */
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.tbl thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  font-weight: 700;
}

table.tbl tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.tbl tbody tr:last-child td {
  border-bottom: none;
}

table.tbl tbody tr:hover {
  background: var(--bg);
}

.user-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.user-name .ph {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all .15s ease;
}

.btn-icon-sm:hover {
  background: var(--purple-soft);
  color: var(--purple);
  border-color: var(--purple-soft);
}

.btn-icon-sm.danger:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red-soft);
}

/* Permission matrix */
.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.perm-table th {
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 6px;
}

.perm-table th:first-child {
  text-align: left;
}

.perm-table td {
  padding: 10px 6px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.perm-table td:first-child {
  text-align: left;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.perm-table .mod-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.perm-check {
  width: 18px;
  height: 18px;
  accent-color: var(--purple);
  cursor: pointer;
}

.role-select-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.role-option {
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  transition: all .15s ease;
}

.role-option:hover {
  border-color: var(--purple-stripe);
}

.role-option.active {
  border-color: var(--purple);
  background: var(--purple-soft);
}

.role-option .ic {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--purple);
}

.role-option strong {
  display: block;
  font-size: 12.5px;
  font-weight: 800;
}

.role-option span {
  font-size: 11px;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 30px;
  margin-bottom: 10px;
  display: block;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

.stat-chip .ic {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.stat-chip .n {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-chip .l {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

#mobileToggle {
  display: none;
}

@media (max-width: 992px) {
  #sidebar {
    display: none;
  }

  #mobileToggle {
    display: inline-flex;
  }

  #content {
    padding: 20px 16px 60px;
  }

  .role-select-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 576px) {
  .perm-table {
    font-size: 11.5px;
  }
}
