/* ============================================================
   ERP Elite — Design System inspirado no TOTVS PO UI
   Vermelho Elite #d60d0f · Roboto · claro e limpo
   Suporta tema escuro via [data-theme="dark"] no <html>.
   ============================================================ */

:root {
  --po-color-primary: #EC1F30;
  --po-color-primary-dark: #c01926;
  --po-color-primary-darker: #8f1219;
  --po-color-primary-light: #fdeaea;

  /* Shell da marca (Equipe Elite) — a sidebar é sempre escura, independente do tema
     claro/escuro do conteúdo, que continua controlado por [data-theme]. */
  --elite-sidebar-bg: #151215;
  --elite-sidebar-surface: #1C191E;
  --elite-sidebar-border: #262329;
  --elite-sidebar-text: #F8F8F8;
  --elite-sidebar-text-muted: #B8B8BB;
  --po-font-display: 'Michroma', 'Poppins', sans-serif;
  --po-color-success: #107048;
  --po-color-success-light: #e3f4ec;
  --po-color-warning: #b7770c;
  --po-color-warning-bg: #efba2a;
  --po-color-warning-light: #fcf3dc;
  --po-color-danger: #9a2a2a;
  --po-color-danger-light: #f5e6e6;
  --po-color-info: #0c6c9c;
  --po-color-info-light: #e3f0f7;

  --po-gray-50: #fafbfc;
  --po-gray-100: #f2f4f6;
  --po-gray-200: #e2e6ea;
  --po-gray-300: #cdd4da;
  --po-gray-400: #9da7b1;
  --po-gray-500: #6e7c8a;
  --po-gray-600: #4a5c6a;
  --po-gray-700: #2c3739;
  --po-gray-800: #1f2729;
  --po-gray-900: #14191b;

  /* Superfícies — sobrescritas no tema escuro */
  --po-bg: var(--po-gray-100);
  --po-surface: #ffffff;
  --po-surface-alt: var(--po-gray-50);
  --po-text: var(--po-gray-700);
  --po-text-strong: var(--po-gray-800);
  --po-border: var(--po-gray-200);

  --po-font: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --po-radius: 2px;
  --po-radius-sm: 2px;
  --po-radius-pill: 3px;
  --po-shadow: 0 1px 4px rgba(0, 0, 0, .12);
  --po-shadow-md: 0 2px 10px rgba(0, 0, 0, .10);
  --po-shadow-lg: 0 16px 48px rgba(18, 23, 28, .18);
  --po-sidebar-width: 268px;
  --po-sidebar-width-collapsed: 68px;
  --po-header-height: 60px;
  --po-focus: 0 0 0 3px rgba(214, 13, 15, .22);
}

[data-theme="dark"] {
  /* Preto Elite (mesma cor da sidebar), não o cinza-azulado genérico do tema
     escuro original — o sistema inteiro deve ficar unificado com a marca. */
  --po-bg: #151215;
  --po-surface: #1C191E;
  --po-surface-alt: #262329;
  --po-text: #cdd4da;
  --po-text-strong: #f2f4f6;
  --po-border: #333f42;
  --po-gray-50: #1a171b;
  --po-gray-100: #262329;
  --po-gray-200: #333f42;
  --po-gray-300: #455356;
  --po-gray-400: #6e7c8a;
  --po-gray-500: #9da7b1;
  --po-gray-600: #cdd4da;
  --po-gray-700: #e2e6ea;
  --po-gray-800: #f2f4f6;
  --po-gray-900: #fafbfc;
  --po-color-primary-light: #3a1414;
  --po-color-success-light: #12271e;
  --po-color-warning-light: #2e2410;
  --po-color-danger-light: #2c1616;
  --po-color-info-light: #102530;
  --po-shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  --po-focus: 0 0 0 3px rgba(255, 75, 77, .28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--po-font);
  font-size: 14px;
  color: var(--po-gray-700);
  background: var(--po-bg);
  height: 100%;
}

a { color: var(--po-color-primary); text-decoration: none; }
a:hover { color: var(--po-color-primary-dark); }

/* ============ LAYOUT ============ */
.po-wrapper { display: flex; min-height: 100vh; }

.po-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--po-sidebar-width);
  transition: margin-left .2s;
}
.po-content { flex: 1; padding: 20px 24px; position: relative; }
.po-content.is-navigating { opacity: .55; transition: opacity .1s ease .08s; }
.po-nav-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: var(--po-color-primary); z-index: 300;
  transition: width .2s ease;
}
.po-nav-progress.on { width: 70%; }
.po-nav-progress.done { width: 100%; transition: width .12s ease, opacity .25s ease .1s; opacity: 0; }

/* ============ SIDEBAR ============ */
.po-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--po-sidebar-width);
  background: var(--elite-sidebar-bg);
  border-right: 2px solid var(--elite-sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform .18s ease, width .18s ease;
}
.po-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 18px;
  height: var(--po-header-height);
  flex-shrink: 0;
  border-bottom: 1px solid var(--elite-sidebar-border);
}
.po-sidebar-brand .brand-logo-full {
  height: 26px;
  width: auto;
  max-width: 158px;
  flex-shrink: 1;
  min-width: 0;
}
/* A sidebar agora é sempre escura (marca Elite), então só a variante clara da logo faz sentido aqui. */
.po-sidebar-brand .brand-logo-full-dark { display: block; }
.po-sidebar-brand .brand-logo-full-light { display: none; }
.po-sidebar-brand .brand-word {
  font-family: var(--po-font-display); font-size: 14px; letter-spacing: 1px;
  color: var(--elite-sidebar-text); line-height: 1.3;
}
.po-sidebar-brand .brand-sub {
  font-size: 9px; font-weight: 700; letter-spacing: 1.6px; color: var(--po-color-primary);
}
.po-sidebar-brand .brand-logo-icon {
  display: none;
  width: 40px; height: 40px;
  flex-shrink: 0;
  object-fit: contain;
}
/* Botão de recolher/expandir — fica no rodapé da navegação (abaixo dos
   módulos), não mais ao lado da logo, para bater com o design de referência. */
.sidebar-collapse-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  margin-top: 6px; padding: 11px 12px; padding-top: 16px;
  border: none; border-top: 1px solid var(--elite-sidebar-border);
  background: transparent;
  border-radius: var(--po-radius-sm);
  color: var(--elite-sidebar-text-muted);
  font: 500 13.5px/1 var(--po-font);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .14s, color .14s;
}
.sidebar-collapse-btn:hover { background: var(--elite-sidebar-surface); color: var(--elite-sidebar-text); }
.sidebar-collapse-btn svg { width: 17px; height: 17px; flex-shrink: 0; transition: transform .25s ease; }
html[data-sidebar="icons"] .sidebar-collapse-btn svg { transform: rotate(180deg); }
html[data-sidebar="icons"] .sidebar-collapse-btn { justify-content: center; }
.sidebar-collapse-btn .label-expandir { display: none; }
/* Recolhido: só o ícone (igual aos demais itens do menu) — o texto "Expandir
   menu" estourava a largura de 68px e ficava com uma estética ruim. */
html[data-sidebar="icons"] .sidebar-collapse-btn .label-recolher,
html[data-sidebar="icons"] .sidebar-collapse-btn .label-expandir { display: none; }

/* --- Corpo rolável do menu --- */
.po-sidebar-nav {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 2px 10px 20px;
  scrollbar-width: thin;
}
.po-sidebar-nav::-webkit-scrollbar { width: 8px; }
.po-sidebar-nav::-webkit-scrollbar-thumb { background: var(--elite-sidebar-border); border-radius: 8px; border: 2px solid var(--elite-sidebar-bg); }
.po-sidebar-nav::-webkit-scrollbar-thumb:hover { background: #3a373d; }

/* --- Seções fixas (favoritos / "todos os módulos") --- */
.po-nav-section-label {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 8px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--elite-sidebar-text-muted);
}
.po-nav-section-label svg { width: 13px; height: 13px; }

/* --- Grupo colapsável --- */
.po-nav-group { margin-bottom: 1px; }
.po-nav-group-head {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: none; background: transparent; border-radius: var(--po-radius-sm);
  color: var(--elite-sidebar-text-muted); font-family: var(--po-font); font-size: 13.5px; font-weight: 600;
  text-align: left; cursor: pointer;
  transition: background .13s, color .13s;
}
.po-nav-group-head:hover { background: var(--elite-sidebar-surface); color: var(--elite-sidebar-text); }
.po-nav-group-head > svg:first-child { width: 17px; height: 17px; flex-shrink: 0; color: var(--elite-sidebar-text-muted); }
.po-nav-group-head .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po-nav-group-head .count {
  font-size: 10.5px; font-weight: 700; color: var(--elite-sidebar-text-muted);
  background: var(--elite-sidebar-surface); border-radius: 20px; padding: 2px 7px;
  transition: opacity .13s;
}
.po-nav-group-head:hover .count { opacity: 0; }
.po-nav-group-head svg:last-child {
  width: 15px; height: 15px; flex-shrink: 0; color: var(--elite-sidebar-text-muted);
  transition: transform .18s ease; margin-left: -22px;
}
.po-nav-group[data-open="1"] .po-nav-group-head svg:last-child { transform: rotate(180deg); }
.po-nav-group[data-open="1"] .po-nav-group-head { color: var(--elite-sidebar-text); }
.po-nav-group[data-current="1"] .po-nav-group-head > svg:first-child { color: var(--po-color-primary); }

.po-nav-group-items { display: none; padding: 2px 0 6px; position: relative; }
.po-nav-group[data-open="1"] .po-nav-group-items { display: block; }
.po-nav-group-items::before {
  content: ''; position: absolute; left: 18px; top: 4px; bottom: 8px;
  width: 1px; background: var(--elite-sidebar-border);
}

/* --- Item --- */
.po-nav-item {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px 7px 14px;
  margin: 1px 0;
  border-radius: var(--po-radius-sm);
  color: var(--elite-sidebar-text-muted);
  font-size: 13px; line-height: 1.35;
  transition: background .13s, color .13s;
}
.po-nav-group-items .po-nav-item { margin-left: 13px; }
.po-nav-item > svg:first-child { width: 16px; height: 16px; flex-shrink: 0; color: var(--elite-sidebar-text-muted); transition: color .13s; }
.po-nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po-nav-item:hover { background: var(--elite-sidebar-surface); color: var(--elite-sidebar-text); }
.po-nav-item:hover > svg:first-child { color: var(--elite-sidebar-text); }
.po-nav-item.active {
  background: var(--elite-sidebar-surface);
  color: var(--elite-sidebar-text);
  font-weight: 600;
}
.po-nav-item.active > svg:first-child { color: var(--po-color-primary); }
.po-nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0; background: var(--po-color-primary);
}

/* --- Botão favoritar --- */
.po-nav-fav {
  flex-shrink: 0; width: 22px; height: 22px; margin-right: -4px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 5px;
  color: #57555a; cursor: pointer;
  opacity: 0; transition: opacity .13s, color .13s, background .13s;
}
.po-nav-fav svg { width: 14px; height: 14px; }
.po-nav-item:hover .po-nav-fav, .po-nav-fav.on { opacity: 1; }
.po-nav-fav:hover { background: var(--elite-sidebar-border); color: var(--po-color-warning); }
.po-nav-fav.on { color: #e8a317; }
.po-nav-fav.on svg { fill: currentColor; }
.po-nav-flat .po-nav-item { margin-left: 0; }

/* --- Resultados de busca (lista plana) --- */
mark { background: rgba(232, 163, 23, .3); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ============ HEADER ============ */
.po-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--po-header-height);
  background: var(--po-surface);
  border-bottom: 1px solid var(--po-gray-200);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.po-header .menu-toggle {
  border: none; background: none; cursor: pointer;
  color: var(--po-gray-500); padding: 7px; border-radius: var(--po-radius-sm);
  display: none; /* só aparece no mobile (ver bloco responsivo) — no desktop o botão fica na sidebar */
}
.po-header .menu-toggle:hover { background: var(--po-gray-100); }

.po-header-heading { min-width: 0; }
.po-header-crumb {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--po-gray-400); font-weight: 600;
  letter-spacing: .03em; text-transform: uppercase;
  margin-bottom: 1px; min-height: 13px;
}
.po-header-title {
  font-family: var(--po-font-display); font-size: 14px; font-weight: 400; letter-spacing: .3px; color: var(--po-gray-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.po-header-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Gatilho de busca no header */
.po-header-search {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px; margin-right: 4px;
  min-width: 210px;
  border: 1px solid var(--po-gray-200); border-radius: var(--po-radius-sm);
  background: var(--po-gray-50); color: var(--po-gray-500);
  font-family: var(--po-font); font-size: 13px; cursor: pointer;
  transition: border-color .14s, background .14s;
}
.po-header-search:hover { border-color: var(--po-gray-300); background: var(--po-surface); }
.po-header-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.po-header-search .grow { flex: 1; text-align: left; }
.po-header-search kbd {
  font-family: inherit; font-size: 10.5px; font-weight: 600; color: var(--po-gray-400);
  background: var(--po-surface); border: 1px solid var(--po-gray-200); border-radius: 4px; padding: 2px 5px;
}

.po-icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; border-radius: var(--po-radius-sm);
  color: var(--po-gray-500); cursor: pointer;
  transition: background .14s, color .14s;
}
.po-icon-btn:hover { background: var(--po-gray-100); color: var(--po-gray-800); }
.po-icon-btn svg { width: 18px; height: 18px; }

.po-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--po-color-primary), var(--po-color-primary-darker));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}

/* Menu do usuário */
.po-user-menu { position: relative; margin-left: 4px; }
.po-user-trigger {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 8px 0 4px;
  border: none; background: none; border-radius: var(--po-radius-pill);
  cursor: pointer; font-family: var(--po-font);
  transition: background .14s;
}
.po-user-trigger:hover { background: var(--po-gray-100); }
.po-user-trigger .uname { font-size: 13px; font-weight: 500; color: var(--po-gray-700); }
.po-user-trigger svg:last-child { width: 14px; height: 14px; color: var(--po-gray-400); }

.po-dropdown {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 250px;
  background: var(--po-surface);
  border: 1px solid var(--po-gray-200);
  border-radius: var(--po-radius);
  box-shadow: var(--po-shadow-lg);
  padding: 8px; z-index: 60;
}
.po-dropdown.open { display: block; }
.po-dropdown .dd-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--po-gray-200); margin-bottom: 6px; }
.po-dropdown .dd-head strong { display: block; color: var(--po-gray-800); font-size: 13.5px; }
.po-dropdown .dd-head span { font-size: 12px; color: var(--po-gray-400); }
.po-dropdown .dd-roles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.po-dropdown .dd-roles .po-tag { text-transform: uppercase; font-size: 10px; }
.po-dropdown .dd-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--po-radius-sm);
  color: var(--po-gray-700); font-size: 13px; cursor: pointer;
}
.po-dropdown .dd-item:hover { background: var(--po-gray-100); color: var(--po-gray-700); }
.po-dropdown .dd-item svg { width: 16px; height: 16px; color: var(--po-gray-400); flex-shrink: 0; }
.po-dropdown .dd-item.danger { color: var(--po-color-primary); }
.po-dropdown .dd-item.danger svg { color: var(--po-color-primary); }

/* Sino de notificações */
.po-notification { position: relative; }
.po-notification .badge-count {
  position: absolute; top: 3px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--po-color-primary); color: #fff;
  border: 2px solid var(--po-surface);
  border-radius: 9px; font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.po-notification-panel {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--po-surface); border: 1px solid var(--po-gray-200);
  border-radius: var(--po-radius); box-shadow: var(--po-shadow-lg);
  z-index: 60;
}
.po-notification-panel.open { display: block; }
.po-notification-panel .np-head {
  padding: 11px 14px; border-bottom: 1px solid var(--po-gray-200);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--po-gray-400);
}
.po-notification-item {
  display: block; padding: 11px 14px;
  border-bottom: 1px solid var(--po-gray-100);
  color: var(--po-gray-700); font-size: 13px;
}
.po-notification-item:hover { background: var(--po-gray-50); }
.po-notification-item .meta { color: var(--po-gray-400); font-size: 11.5px; margin-top: 2px; }

/* ============ PAGE HEADER / BREADCRUMB / TOOLBAR ============ */
.po-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--po-gray-400);
  margin-bottom: 6px;
}
.po-breadcrumb a { color: var(--po-gray-500); }
.po-breadcrumb .sep { color: var(--po-gray-300); }

.po-page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.po-page-header h1 { margin: 0; font-family: var(--po-font-display); font-size: 19px; font-weight: 400; letter-spacing: .3px; color: var(--po-gray-800); }
.po-page-header .subtitle { margin: 4px 0 0; color: var(--po-gray-500); font-size: 13px; }
.po-toolbar { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============ BOTÕES ============ */
.po-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--po-radius-pill);
  font-family: var(--po-font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--po-color-primary);
  color: #fff;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
  line-height: 1.4;
}
.po-button:hover { background: var(--po-color-primary-dark); color: #fff; }
.po-button:active { background: var(--po-color-primary-darker); }
.po-button svg { width: 15px; height: 15px; }

.po-button-secondary {
  background: var(--po-surface);
  color: var(--po-color-primary);
  border-color: var(--po-color-primary);
}
.po-button-secondary:hover { background: var(--po-color-primary-light); color: var(--po-color-primary-dark); }

.po-button-danger { background: var(--po-color-danger); }
.po-button-danger:hover { background: #9e332d; }

.po-button-link {
  background: none; color: var(--po-color-primary); border: none; padding: 8px 10px;
}
.po-button-link:hover { background: var(--po-color-primary-light); color: var(--po-color-primary-dark); }

.po-button-sm { padding: 5px 12px; font-size: 12.5px; }
.po-button:disabled { opacity: .55; cursor: not-allowed; }

/* ============ FORMULÁRIOS ============ */
.po-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.po-field label { font-size: 12.5px; font-weight: 600; color: var(--po-gray-600); }
.po-field .hint { font-size: 11.5px; color: var(--po-gray-400); }
.po-field .req { color: var(--po-color-danger); }

.po-input, .po-select, .po-textarea {
  font-family: var(--po-font);
  font-size: 13.5px;
  color: var(--po-gray-700);
  padding: 8px 12px;
  border: 1px solid var(--po-gray-300);
  border-radius: var(--po-radius);
  background: var(--po-surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.po-input:focus, .po-select:focus, .po-textarea:focus {
  border-color: var(--po-color-primary);
  box-shadow: 0 0 0 3px rgba(214, 13, 15, .15);
}
.po-textarea { min-height: 84px; resize: vertical; }
.po-select { appearance: auto; }

.po-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}
.po-form-grid .span-2 { grid-column: span 2; }
.po-form-grid .span-full { grid-column: 1 / -1; }

.po-checkbox { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--po-gray-600); }

/* ============ CARDS / WIDGETS ============ */
.po-card {
  background: var(--po-surface);
  border: 1px solid var(--po-gray-200);
  border-radius: var(--po-radius);
  box-shadow: var(--po-shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.po-card-title {
  margin: 0 0 14px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .2px;
  color: var(--po-gray-800);
}

.po-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
/* Entrada animada dos cards de KPI, como no design de referência — cada card
   surge com um pequeno atraso em cascata em vez de aparecer tudo de uma vez. */
@keyframes po-kpi-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.po-kpi-grid > * { animation: po-kpi-in .5s cubic-bezier(.16,1,.3,1) both; }
.po-kpi-grid > *:nth-child(1) { animation-delay: 0ms; }
.po-kpi-grid > *:nth-child(2) { animation-delay: 70ms; }
.po-kpi-grid > *:nth-child(3) { animation-delay: 140ms; }
.po-kpi-grid > *:nth-child(4) { animation-delay: 210ms; }
.po-kpi-grid > *:nth-child(5) { animation-delay: 280ms; }
.po-kpi-grid > *:nth-child(6) { animation-delay: 350ms; }
.po-kpi-grid > *:nth-child(7) { animation-delay: 420ms; }
.po-kpi-grid > *:nth-child(8) { animation-delay: 490ms; }
@media (prefers-reduced-motion: reduce) { .po-kpi-grid > * { animation: none; } }
.po-widget {
  position: relative;
  background: var(--po-surface);
  border: 1px solid var(--po-gray-200);
  border-radius: var(--po-radius);
  box-shadow: var(--po-shadow);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  overflow: hidden;
}
.po-widget::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--po-color-primary); }
.po-widget.tone-success::before { background: var(--po-color-success); }
.po-widget.tone-warning::before { background: var(--po-color-warning); }
.po-widget.tone-danger::before { background: var(--po-color-danger); }
.po-widget .w-icon {
  width: 40px; height: 40px; border-radius: 2px; flex-shrink: 0;
  background: var(--po-color-primary-light); color: var(--po-color-primary-dark);
  display: flex; align-items: center; justify-content: center;
}
.po-widget .w-icon svg { width: 20px; height: 20px; }
.po-widget.tone-success .w-icon { background: var(--po-color-success-light); color: var(--po-color-success); }
.po-widget.tone-warning .w-icon { background: var(--po-color-warning-light); color: var(--po-color-warning); }
.po-widget.tone-danger .w-icon { background: var(--po-color-danger-light); color: var(--po-color-danger); }
.po-widget .w-label { font-size: 11.5px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase; color: var(--po-gray-500); }
.po-widget .w-value { font-family: var(--po-font-display); font-size: 20px; font-weight: 400; color: var(--po-gray-800); line-height: 1.3; }
.po-widget .w-hint { font-size: 11.5px; color: var(--po-gray-400); }

/* ============ GRÁFICOS ANIMADOS (estilo do design de referência) ============ */
.elite-bars { display: flex; align-items: flex-end; gap: 14px; height: 150px; margin-top: 4px; }
.elite-bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.elite-bars .bar-val { font-size: 11px; font-weight: 700; color: var(--po-text-strong); }
.elite-bars .bar-group { display: flex; align-items: flex-end; gap: 4px; height: 100%; }
.elite-bars .bar-fill { width: 14px; border-radius: 2px 2px 0 0; background: var(--po-color-primary); height: 0%; transition: height 1.4s cubic-bezier(.16,1,.3,1); }
.elite-bars .bar-fill.despesa { background: var(--po-gray-400); }
.elite-bars .bar-label { font-size: 11px; color: var(--po-gray-400); }
.elite-bars-legend { display: flex; align-items: center; gap: 18px; margin-bottom: 10px; font-size: 12px; color: var(--po-text); }
.elite-bars-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.elite-segbar { display: flex; height: 14px; border-radius: 2px; overflow: hidden; margin: 4px 0 16px; background: var(--po-gray-100); }
.elite-segbar .seg { flex: 0; transition: flex 1.4s cubic-bezier(.16,1,.3,1); }
.elite-seglegend { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.elite-seglegend .dot { width: 9px; height: 9px; flex-shrink: 0; border-radius: 1px; }
.elite-seglegend .lbl { color: var(--po-text); font-size: 12.5px; flex: 1; }
.elite-seglegend .cnt { color: var(--po-text-strong); font-size: 12.5px; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .elite-bars .bar-fill, .elite-segbar .seg { transition: none; } }

/* ============ TABELAS ============ */
.po-table-wrap { overflow-x: auto; background: var(--po-surface); border: 1px solid var(--po-gray-200); border-radius: var(--po-radius); box-shadow: var(--po-shadow); }
.po-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.po-table thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--po-gray-50);
  color: var(--po-gray-500);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--po-gray-200);
  white-space: nowrap;
}
.po-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--po-gray-100);
  color: var(--po-gray-700);
  vertical-align: middle;
}
.po-table tbody tr:hover { background: var(--po-gray-50); }
.po-table tbody tr:last-child td { border-bottom: none; }
.po-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.po-table .actions { text-align: right; white-space: nowrap; }
.po-table .actions a { margin-left: 10px; font-size: 12.5px; font-weight: 500; }
.po-table .empty { text-align: center; padding: 32px; color: var(--po-gray-400); }

/* ============ TAGS (badges) ============ */
.po-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--po-radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.po-tag-success { background: var(--po-color-success-light); color: var(--po-color-success); }
.po-tag-warning { background: var(--po-color-warning-light); color: var(--po-color-warning); }
.po-tag-danger  { background: var(--po-color-danger-light); color: var(--po-color-danger); }
.po-tag-info    { background: var(--po-color-info-light); color: var(--po-color-info); }
.po-tag-neutral { background: var(--po-gray-100); color: var(--po-gray-500); }
.po-tag-primary { background: var(--po-color-primary-light); color: var(--po-color-primary-dark); }

/* ============ FILTROS ============ */
.po-filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.po-filters .po-field { margin-bottom: 0; min-width: 160px; }
.po-filters .po-input, .po-filters .po-select { width: auto; min-width: 160px; }

/* ============ PAGINAÇÃO ============ */
.po-pagination {
  display: flex; align-items: center; gap: 4px;
  margin-top: 14px; justify-content: flex-end;
  font-size: 13px;
}
.po-pagination a, .po-pagination span.current {
  padding: 5px 11px; border-radius: 6px; color: var(--po-gray-600);
}
.po-pagination a:hover { background: var(--po-gray-200); }
.po-pagination span.current { background: var(--po-color-primary); color: #fff; font-weight: 600; }
.po-pagination .total { margin-right: auto; color: var(--po-gray-400); font-size: 12.5px; }

/* ============ MODAL ============ */
.po-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 25, 27, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px;
  z-index: 100;
  overflow-y: auto;
}
.po-modal {
  background: var(--po-surface);
  border-radius: var(--po-radius);
  box-shadow: var(--po-shadow-md);
  width: 100%;
  max-width: 640px;
}
.po-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--po-gray-200);
}
.po-modal-header h3 { margin: 0; font-size: 16px; font-weight: 500; }
.po-modal-header .close { border: none; background: none; cursor: pointer; font-size: 20px; color: var(--po-gray-400); }
.po-modal-body { padding: 20px; }
.po-modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--po-gray-200);
}

/* ============ TOASTS ============ */
.po-toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.po-toast {
  min-width: 260px; max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--po-radius);
  box-shadow: var(--po-shadow-md);
  background: var(--po-surface);
  border-left: 4px solid var(--po-color-info);
  font-size: 13.5px;
  animation: toastIn .25s ease;
}
.po-toast.success { border-left-color: var(--po-color-success); }
.po-toast.error   { border-left-color: var(--po-color-danger); }
.po-toast.warning { border-left-color: var(--po-color-warning-bg); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ============ TABS ============ */
.po-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--po-gray-200); margin-bottom: 18px; flex-wrap: wrap; }
.po-tab {
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--po-gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
}
.po-tab:hover { color: var(--po-color-primary); }
.po-tab.active { color: var(--po-color-primary-dark); border-bottom-color: var(--po-color-primary); }

/* ============ TIMELINE (eventos) ============ */
.po-timeline { list-style: none; margin: 0; padding: 0; }
.po-timeline li {
  position: relative;
  padding: 0 0 18px 24px;
  border-left: 2px solid var(--po-gray-200);
  margin-left: 8px;
}
.po-timeline li::before {
  content: '';
  position: absolute;
  left: -7px; top: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--po-color-primary);
  border: 2px solid var(--po-surface);
  box-shadow: 0 0 0 1px var(--po-gray-300);
}
.po-timeline .tl-meta { font-size: 11.5px; color: var(--po-gray-400); }

/* ============ KANBAN (central de eventos) ============ */
.po-kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.po-kanban-col { background: var(--po-gray-100); border-radius: var(--po-radius); padding: 10px; }
.po-kanban-col h4 { margin: 2px 6px 10px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--po-gray-500); display: flex; justify-content: space-between; }
.po-kanban-card {
  background: var(--po-surface); border: 1px solid var(--po-gray-200); border-radius: var(--po-radius);
  box-shadow: var(--po-shadow); padding: 12px; margin-bottom: 8px; display: block; color: var(--po-gray-700);
}
.po-kanban-card:hover { border-color: var(--po-color-primary); color: var(--po-gray-700); }
.po-kanban-card .k-title { font-weight: 600; font-size: 13px; }
.po-kanban-card .k-meta { font-size: 11.5px; color: var(--po-gray-400); margin-top: 4px; }
.po-kanban-card.sla-estourado { border-left: 4px solid var(--po-color-danger); }

/* ============ LOGIN ============ */
.po-login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--po-color-primary-darker) 0%, var(--po-color-primary) 100%);
  padding: 16px;
}
.po-login-card {
  background: var(--po-surface); border-radius: 12px; box-shadow: var(--po-shadow-md);
  width: 100%; max-width: 400px; padding: 36px 32px;
}
.po-login-card .login-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 26px; }
.po-login-card .login-brand .brand-logo-full { height: 36px; width: auto; max-width: 100%; }
.po-login-card .login-brand .brand-logo-full-dark { display: none; }
.po-login-card .login-brand .brand-logo-full-light { display: block; }
html[data-theme="dark"] .po-login-card .login-brand .brand-logo-full-dark { display: block; }
html[data-theme="dark"] .po-login-card .login-brand .brand-logo-full-light { display: none; }
.po-login-card h1 { margin: 0; font-size: 19px; font-weight: 600; color: var(--po-gray-800); }
.po-login-card .sub { font-size: 12px; color: var(--po-gray-400); }
.po-login-card .po-button { width: 100%; margin-top: 6px; }
.po-login-error {
  background: var(--po-color-danger-light); color: var(--po-color-danger);
  padding: 10px 14px; border-radius: var(--po-radius); font-size: 13px; margin-bottom: 14px;
}

/* ============ UTILITÁRIOS ============ */
.text-muted { color: var(--po-gray-400); }
.text-danger { color: var(--po-color-danger); }
.text-success { color: var(--po-color-success); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============ RESPONSIVO ============ */
.po-scrim { display: none; position: fixed; inset: 0; background: rgba(18, 23, 28, .4); z-index: 45; }
@media (max-width: 1024px) {
  .po-sidebar { transform: translateX(-100%); box-shadow: none; }
  .po-main { margin-left: 0 !important; }
  body.sidebar-open .po-sidebar { transform: none; box-shadow: var(--po-shadow-lg); }
  body.sidebar-open .po-scrim { display: block; }
  .po-header .menu-toggle { display: flex; }
  .sidebar-collapse-btn { display: none; }
  .po-header-search { min-width: 0; }
  .po-header-search .grow, .po-header-search kbd { display: none; }
  /* No mobile o modo ícone não existe — a gaveta sempre abre com o menu completo */
  html[data-sidebar="icons"] { --po-sidebar-width: 268px; }
  html[data-sidebar="icons"] .brand-text { display: block !important; }
  html[data-sidebar="icons"] .po-nav-group-head .label,
  html[data-sidebar="icons"] .po-nav-group-head .count,
  html[data-sidebar="icons"] .po-nav-group-head svg:last-child { display: block; }
  html[data-sidebar="icons"] .po-nav-group-items { display: none !important; }
  html[data-sidebar="icons"] .po-nav-group[data-open="1"] .po-nav-group-items { display: block !important; }
  html[data-sidebar="icons"] .po-nav-flyout { display: none !important; }
  html[data-sidebar="icons"] .po-nav-section-label { justify-content: flex-start; padding: 14px 8px 6px; }
  html[data-sidebar="icons"] .po-nav-section-label span { display: block; }
}

@media (max-width: 600px) {
  html, body, .po-wrapper, .po-main { max-width: 100%; overflow-x: hidden; }
  .po-content { min-width: 0; max-width: 100%; padding: 14px 12px; }
  .po-card, .po-table-wrap { min-width: 0; max-width: 100%; }
  .po-card { padding: 14px 12px; }
  .po-card > .po-table { display: block; max-width: 100%; overflow-x: auto; }
  .po-page-header { gap: 10px; margin-bottom: 14px; }
  .po-page-header h1 { font-size: 20px; }
  .po-toolbar { width: 100%; margin-left: 0; }
  .po-filters { align-items: stretch; }
  .po-filters .po-field, .po-filters .po-input, .po-filters .po-select { width: 100%; min-width: 0; }
  .po-form-grid { grid-template-columns: 1fr; }
  .po-form-grid .span-2 { grid-column: span 1; }
  .po-kpi-grid { grid-template-columns: 1fr; }
  .po-user-trigger .uname, .po-user-trigger svg:last-child { display: none; }
  .po-palette-overlay { padding: 6vh 10px 10px; }
}

/* ============ SIDEBAR — MODO ÍCONES (desktop) ============ */
html[data-sidebar="icons"] { --po-sidebar-width: var(--po-sidebar-width-collapsed); }
html[data-sidebar="icons"] .po-sidebar-nav { overflow: visible; padding: 6px 8px 20px; }
html[data-sidebar="icons"] .po-sidebar-brand { justify-content: center; padding: 0 8px; position: relative; }
html[data-sidebar="icons"] .brand-logo-full { display: none !important; }
html[data-sidebar="icons"] .brand-logo-icon { display: block; }
html[data-sidebar="icons"] .brand-text { display: none !important; }
html[data-sidebar="icons"] .po-nav-section-label { justify-content: center; padding: 12px 0 4px; }
html[data-sidebar="icons"] .po-nav-section-label span { display: none; }
html[data-sidebar="icons"] .po-nav-group-head .label,
html[data-sidebar="icons"] .po-nav-group-head .count,
html[data-sidebar="icons"] .po-nav-group-head svg:last-child { display: none; }
html[data-sidebar="icons"] .po-nav-group-head { justify-content: center; padding: 10px 0; }
html[data-sidebar="icons"] .po-nav-group[data-current="1"] .po-nav-group-head { background: var(--po-color-primary-light); }
html[data-sidebar="icons"] .po-nav-group-items { display: none !important; }
/* itens soltos (favoritos) no modo ícone */
html[data-sidebar="icons"] .po-nav-flat .po-nav-item { justify-content: center; padding: 8px 0; }
html[data-sidebar="icons"] .po-nav-flat .po-nav-item .label,
html[data-sidebar="icons"] .po-nav-flat .po-nav-item .po-nav-fav { display: none; }
html[data-sidebar="icons"] .po-nav-item.active::before { display: none; }

/* Flyout do grupo no modo ícone */
.po-nav-flyout { display: none; }
html[data-sidebar="icons"] .po-nav-group { position: relative; }
html[data-sidebar="icons"] .po-nav-group:hover > .po-nav-flyout,
html[data-sidebar="icons"] .po-nav-group:focus-within > .po-nav-flyout { display: block; }
html[data-sidebar="icons"] .po-nav-flyout {
  position: absolute; left: calc(100% + 6px); top: -6px;
  min-width: 232px; max-height: 70vh; overflow-y: auto;
  padding: 8px;
  background: var(--elite-sidebar-surface);
  border: 1px solid var(--elite-sidebar-border);
  border-radius: var(--po-radius);
  box-shadow: var(--po-shadow-lg);
  z-index: 70;
}
html[data-sidebar="icons"] .po-nav-flyout .flyout-title {
  padding: 4px 8px 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--elite-sidebar-border);
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--elite-sidebar-text-muted);
}
html[data-sidebar="icons"] .po-nav-flyout .po-nav-item { margin-left: 0; padding-left: 10px; }
html[data-sidebar="icons"] .po-nav-flyout .po-nav-item::before { display: none; }

/* ============ TEMA — botão sol/lua ============ */
.theme-toggle .icon-sun, .theme-toggle .icon-moon { display: flex; align-items: center; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: flex; }

/* ============ COMMAND PALETTE (Ctrl+K) ============ */
.po-palette-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(18, 23, 28, .45);
  padding: 12vh 16px 16px;
}
.po-palette-overlay.open { display: block; }
.po-palette {
  max-width: 620px; margin: 0 auto;
  background: var(--po-surface);
  border: 1px solid var(--po-gray-200);
  border-radius: 14px;
  box-shadow: var(--po-shadow-lg);
  overflow: hidden;
}
.po-palette-input {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px; height: 58px;
  border-bottom: 1px solid var(--po-gray-200);
}
.po-palette-input > svg { width: 19px; height: 19px; color: var(--po-gray-400); flex-shrink: 0; }
.po-palette-input input {
  flex: 1; border: none; background: none; outline: none;
  font-family: var(--po-font); font-size: 16px; color: var(--po-gray-800);
}
.po-palette-input input::placeholder { color: var(--po-gray-400); }
.po-palette-input .esc {
  font-size: 10.5px; font-weight: 600; color: var(--po-gray-400);
  border: 1px solid var(--po-gray-200); border-radius: 4px; padding: 3px 6px;
}
.po-palette-list { max-height: 46vh; overflow-y: auto; padding: 8px; }
.po-palette-group {
  padding: 10px 10px 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--po-gray-400);
}
.po-palette-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--po-radius-sm);
  cursor: pointer; font-size: 13.5px; color: var(--po-gray-700);
}
.po-palette-item > svg:first-child { width: 17px; height: 17px; color: var(--po-gray-400); flex-shrink: 0; }
.po-palette-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po-palette-item .where { font-size: 11px; color: var(--po-gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.po-palette-item.sel { background: var(--po-color-primary-light); color: var(--po-color-primary-dark); }
.po-palette-item.sel > svg:first-child, .po-palette-item.sel .where { color: var(--po-color-primary); }
.po-palette-empty { padding: 34px 16px; text-align: center; color: var(--po-gray-400); font-size: 13.5px; }
.po-palette-foot {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; border-top: 1px solid var(--po-gray-200);
  background: var(--po-gray-50);
  font-size: 11.5px; color: var(--po-gray-400);
}
.po-palette-foot kbd {
  font-family: inherit; font-weight: 600;
  border: 1px solid var(--po-gray-200); background: var(--po-surface);
  border-radius: 4px; padding: 1px 5px; margin-right: 4px;
}
