/* ============================================================
   MO'AR - Global Style
   ============================================================ */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sidebar-bg: #0F1117;
  --sidebar-w: 200px;
  --topbar-h: 52px;
  --bg: #F0F2F5;
  --surface: #FFFFFF;
  --surface2: #F7F8FA;
  --border: #E4E7EC;
  --border-dark: #D1D5DB;
  --ink: #111827;
  --body: #374151;
  --muted: #6B7280;
  --hint: #9CA3AF;
  --accent: #00B4A0;
  --accent-dim: #00967F;
  --accent-glow: rgba(0, 180, 160, .12);
  --red: #E53935;
  --green: #22A06B;
  --amber: #F59E0B;
  --blue: #3B82F6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 4px 12px rgba(0, 0, 0, .04);
}

html {
  font-size: 14px;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
}

/* ── Main (sem sidebar) ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: 0;
}

/* ── Topbar: 3 colunas (esquerda / centro / direita) ── */
.topbar {
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Centro: logo/nome */
.tb-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.tb-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .04em;
}

/* Direita: usuario + sair */
.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

/* Botao home/voltar destacado */
.tb-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .65);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}

.tb-home-btn:hover {
  background: rgba(255, 255, 255, .13);
  border-color: rgba(255, 255, 255, .2);
  color: #fff;
}

.tb-home-btn svg {
  flex-shrink: 0;
}

.tb-spacer {
  flex: 1;
}

.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .13s;
  white-space: nowrap;
  text-decoration: none;
}

.tb-btn.ghost {
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .55);
  border: 1px solid rgba(255, 255, 255, .08);
}

.tb-btn.ghost:hover {
  background: rgba(255, 255, 255, .11);
  color: #fff;
}

.tb-btn.accent {
  background: var(--accent);
  color: #fff;
}

.tb-btn.accent:hover {
  background: var(--accent-dim);
}

.tb-user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, .08);
}

.tb-user-name {
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  line-height: 1.2;
  text-align: right;
}

.tb-user-role {
  font-size: 10.5px;
  color: rgba(255, 255, 255, .35);
  text-align: right;
}

.u-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00B4A0, #007B6E);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* Topbar page info (titulo + sub) */
.topbar-page {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.topbar-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, .35);
  margin-top: 1px;
}

/* ── Content ── */
.content {
  flex: 1;
  padding: 24px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.ch-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.ch-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.ch-spacer {
  flex: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .13s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border-dark);
  color: var(--muted);
}

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

.btn-dark {
  background: var(--ink);
  color: #fff;
}

.btn-dark:hover {
  background: #1F2937;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-dim);
}

.btn-danger {
  background: #FEE8E8;
  color: var(--red);
  border: 1px solid #FECACA;
}

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

.btn-sm {
  height: 27px;
  padding: 0 10px;
  font-size: 12px;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: .03em;
}

.form-control {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface2);
  color: var(--ink);
  outline: none;
  transition: border-color .13s, background .13s;
}

.form-control:focus {
  border-color: var(--accent);
  background: var(--surface);
}

textarea.form-control {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

.form-select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  padding: 0 26px 0 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
  color: var(--ink);
  outline: none;
  appearance: none;
  transition: border-color .13s;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--accent);
}

/* ── Table ── */
.tbl {
  width: 100%;
  border-collapse: collapse;
}

.tbl th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 14px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  vertical-align: middle;
  color: var(--body);
}

.tbl tbody tr {
  cursor: pointer;
  transition: background .1s;
}

.tbl tbody tr:hover td {
  background: var(--surface2);
}

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

.tbl-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

.tbl-foot span {
  font-size: 12px;
  color: var(--muted);
}

/* ── Status Pills ── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.status .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.s-ativo {
  background: #E6F7F2;
  color: #057A55;
}

.s-inativo {
  background: #F3F4F6;
  color: #6B7280;
}

.s-ferias {
  background: #EFF6FF;
  color: #1D4ED8;
}

.s-afastado {
  background: #FEF3C7;
  color: #92400E;
}

/* ── Tags ── */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg);
  color: var(--muted);
}

/* ── KPI Card ── */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .14s;
  box-shadow: var(--shadow);
}

.kpi:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, .07);
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-trend {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
}

.trend-up {
  background: #E8F5EE;
  color: var(--green);
}

.trend-down {
  background: #FEE8E8;
  color: var(--red);
}

.trend-flat {
  background: #F3F4F6;
  color: var(--muted);
}

.kpi-val {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-lbl {
  font-size: 12px;
  color: var(--muted);
}

.kpi-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 14px;
  overflow: hidden;
}

.kpi-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-in .2s ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(.96) translateY(-8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-title {
  font-size: 14px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 2px;
  transition: color .12s;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Alert ── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 12px;
}

.alert-ok {
  background: #E6F7F2;
  color: #057A55;
  border: 1px solid #BBF7D0;
}

.alert-err {
  background: #FEE8E8;
  color: var(--red);
  border: 1px solid #FECACA;
}

.alert-warn {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FDE68A;
}

/* ── Overlay ── */
.overlay-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 99;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

.overlay-bg.on {
  opacity: 1;
  pointer-events: all;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .2);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

#toast.show {
  opacity: 1;
}

#toast.ok {
  background: #057A55;
}

#toast.err {
  background: var(--red);
}

/* ── Spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ── Grids ── */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.grid-main {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
}

/* ── Utilities ── */
.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 4px;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.ml-auto {
  margin-left: auto;
}

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

.text-sm {
  font-size: 12px;
}

.fw-500 {
  font-weight: 500;
}

.fw-600 {
  font-weight: 600;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 16px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 16px;
}

.mb-4 {
  margin-bottom: 24px;
}

.p-0 {
  padding: 0;
}

.overflow-auto {
  overflow-x: auto;
}

/* ── Responsive ── */
@media (max-width: 760px) {
  .content {
    padding: 16px;
  }

  .topbar {
    padding: 0 14px;
  }

  .tb-user-chip {
    display: none;
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
  }
}

@media (max-width: 480px) {
  .topbar-sub {
    display: none;
  }

  .content {
    padding: 12px;
  }

  .tb-logo-text {
    font-size: 14px;
  }
}

@media (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  flex-shrink: 0;
}

/* Desktop: sidebar empurra o conteúdo */
@media (min-width: 769px) {
  .main {
    margin-left: var(--sidebar-w);
  }
}

/* Mobile: sidebar oculta fora da tela */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, .3);
  }

  .main {
    margin-left: 0;
  }
}

/* Botão hamburguer */
.ham {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .55);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 5px;
  transition: color .12s;
}

.ham:hover {
  color: #fff;
}

@media (min-width: 769px) {
  .ham {
    display: none;
  }
}

/* Logo */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 52px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  flex-shrink: 0;
}

.sb-logo-txt {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .06em;
  flex: 1;
}

.sb-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .35);
  cursor: pointer;
  font-size: 18px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color .12s;
}

.sb-close:hover {
  color: #fff;
}

@media (min-width: 769px) {
  .sb-close {
    display: none;
  }
}

/* Área de navegação */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: none;
}

.sb-nav::-webkit-scrollbar {
  display: none;
}

/* Link simples */
.sb-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  margin: 1px 6px;
  border-radius: 7px;
  color: rgba(255, 255, 255, .5);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .12s, color .12s;
  cursor: pointer;
}

.sb-link svg {
  flex-shrink: 0;
}

.sb-link:hover {
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .85);
}

.sb-link.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.sb-link.active svg {
  stroke: var(--accent);
}

/* Botão de grupo (accordion) */
.sb-group-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: calc(100% - 12px);
  padding: 8px 14px;
  margin: 1px 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, .5);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  border-radius: 7px;
  transition: background .12s, color .12s;
}

.sb-group-toggle svg {
  flex-shrink: 0;
}

.sb-group-toggle:hover {
  background: rgba(255, 255, 255, .07);
  color: rgba(255, 255, 255, .85);
}

.sb-group-toggle.active {
  color: var(--accent);
}

.sb-group-toggle.active svg:not(.sb-chevron) {
  stroke: var(--accent);
}

/* Chevron de expansão */
.sb-chevron {
  margin-left: auto;
  transition: transform .2s;
  stroke: currentColor;
  flex-shrink: 0;
}

.sb-group.open .sb-chevron {
  transform: rotate(180deg);
}

/* Sub-menu */
.sb-sub {
  display: none;
  padding-bottom: 4px;
}

.sb-sub.open {
  display: block;
}

.sb-sub-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 34px;
  margin: 1px 6px;
  border-radius: 6px;
  color: rgba(255, 255, 255, .38);
  font-size: 12px;
  font-weight: 400;
  text-decoration: none;
  transition: background .12s, color .12s;
}

.sb-sub-link svg {
  flex-shrink: 0;
}

.sb-sub-link:hover {
  background: rgba(255, 255, 255, .06);
  color: rgba(255, 255, 255, .75);
}

.sb-sub-link.active {
  color: var(--accent);
  background: rgba(0, 180, 160, .08);
}

.sb-sub-link.active svg {
  stroke: var(--accent);
}

/* Badges de status */
.sb-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.sb-badge.txt {
  background: rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .4);
}

.sb-badge.beta {
  background: rgba(59, 130, 246, .25);
  color: #93C5FD;
}

.sb-badge.manutencao {
  background: rgba(245, 158, 11, .2);
  color: #FCD34D;
}

/* Rodapé do sidebar */
.sb-footer {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: 10px 14px;
  flex-shrink: 0;
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sb-user-name {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, .7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-user-role {
  font-size: 10.5px;
  color: rgba(255, 255, 255, .3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}