/* ==========================================================================
   VAGAS CTRL — Sistema Visual Corporativo Executivo
   Tipografia: Gotham / Gotham Pro / Montserrat (100% da interface)
   Cores Semânticas Vivas Calibradas:
   - Aberta: Cyan (#38bdf8)
   - Fechada: Esmeralda (#3fb950)
   - Atenção / 30-60d / Obs: Âmbar (#e3b341)
   - Crítico / >60d / Perigo: Vermelho (#f85149)
   - Rotatividade / Ciclos: Ametista (#a371f7)
   ========================================================================== */

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

:root{
  /* --- Superfícies Sólidas Corporativas --- */
  --bg: #0d1117;
  --bg-subtle: #111620;
  --surface: #161b22;
  --surface-hover: #1c2128;
  --surface-2: #21262d;
  --surface-3: #2d333b;
  --surface-glass: rgba(22, 27, 34, 0.94);
  --border: #30363d;
  --border-strong: #444c56;
  --border-focus: #58a6ff;

  /* compatibilidade */
  --panel: var(--surface);
  --panel-2: var(--surface-2);

  /* --- Tipografia & Cores de Texto --- */
  --text: #f0f6fc;
  --text-2: #c9d1d9;
  --muted: #8b949e;
  --subtle: #6e7681;

  /* --- Cores Semânticas Vivas --- */
  --accent: #38bdf8;          /* Cyan vibrante */
  --accent-hover: #7dd3fc;
  --accent-dim: rgba(56, 189, 248, 0.14);
  --on-accent: #041017;

  --ok: #238636;              /* Verde corporativo */
  --ok-text: #3fb950;
  --ok-dim: rgba(63, 185, 80, 0.14);

  --warn: #d29922;            /* Âmbar / atenção */
  --warn-text: #e3b341;
  --warn-dim: rgba(227, 179, 65, 0.14);

  --crit: #da3633;            /* Vermelho crítico */
  --crit-text: #f85149;
  --crit-dim: rgba(248, 81, 73, 0.14);

  --purple: #8957e5;          /* Roxo rotatividade */
  --purple-text: #a371f7;
  --purple-dim: rgba(163, 113, 247, 0.14);

  /* --- Raios e Sombras --- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.6);

  /* --- Tipografia Gotham em todo o sistema --- */
  --font-family: 'Gotham', 'Gotham Pro', 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-sans: var(--font-family);
  --font-mono: var(--font-family);

  --step-eyebrow: 11px;
  --step-xs: 12px;
  --step-sm: 13px;
  --step-base: 14px;
  --step-md: 15px;
  --step-lg: 18px;
  --step-xl: 22px;
  --step-2xl: 26px;

  /* --- Espaçamento --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --shell-max: 1480px;
  --shell-pad: 24px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: var(--step-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  min-height: 100vh;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

/* Barras de rolagem discretas */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Utilitários tipográficos */
.mono {
  font-family: var(--font-family);
  font-variant-numeric: tabular-nums;
}
.display { font-weight: 700; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ==========================================================================
   SHELL DO DASHBOARD
   ========================================================================== */

.wrap {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--space-4) var(--shell-pad) 48px;
}

/* ==========================================================================
   HEADER CORPORATIVO
   ========================================================================== */

header.top {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100%;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.top-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 10px var(--shell-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  user-select: none;
}

.brand .mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
}

.brand h1 {
  font-size: var(--step-md);
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  color: #ffffff;
}

.brand p {
  margin: 2px 0 0;
  font-size: var(--step-xs);
  color: var(--muted);
  line-height: 1.3;
}

.header-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

/* Barra do usuário logado */
.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--step-xs);
  color: var(--muted);
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.userbar .who {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  text-align: right;
  min-width: 0;
}

.userbar .who .name {
  color: var(--text);
  font-weight: 600;
  font-size: var(--step-xs);
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
}
.role-badge.editor {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.role-badge.viewer {
  background: var(--surface-3);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Navegação em abas */
nav.tabs {
  display: flex;
  gap: 4px;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 var(--shell-pad);
  overflow-x: auto;
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }

nav.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-size: var(--step-sm);
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s var(--ease);
}
nav.tabs a svg { opacity: 0.7; flex-shrink: 0; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a:hover svg { opacity: 1; }
nav.tabs a.active {
  color: #ffffff;
  border-bottom-color: var(--accent);
}
nav.tabs a.active svg { opacity: 1; color: var(--accent); }

/* ==========================================================================
   BOTÕES CORPORATIVOS
   ========================================================================== */

.btn {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: var(--step-sm);
  letter-spacing: -0.01em;
  line-height: 1.2;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--accent-hover);
}
.btn:active {
  opacity: 0.9;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn.ghost:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: #ffffff;
}

.btn.small {
  padding: 5px 10px;
  font-size: var(--step-xs);
  border-radius: var(--radius-xs);
}

.btn.danger {
  background: var(--crit-dim);
  color: var(--crit-text);
  border-color: rgba(248, 81, 73, 0.3);
}
.btn.danger:hover {
  background: var(--crit);
  color: #ffffff;
}

.btn.ok {
  background: var(--ok-dim);
  color: var(--ok-text);
  border-color: rgba(63, 185, 80, 0.3);
}
.btn.ok:hover {
  background: var(--ok);
  color: #ffffff;
}

.btn.full { width: 100%; }

.btn.icon-only {
  position: relative;
  padding: 0;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  gap: 0;
  border-radius: var(--radius-xs);
}
.btn.icon-only .cycle-badge {
  position: absolute;
  top: -5px;
  right: -7px;
  margin: 0;
  pointer-events: none;
}

.icon { display: inline-block; flex-shrink: 0; vertical-align: -2px; }

/* ==========================================================================
   MENU (Popover API) & DROPDOWNS
   ========================================================================== */

.menu-panel {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: max-content;
  min-width: 240px;
  max-width: min(340px, calc(100vw - 24px));
  color: var(--text);
  z-index: 60;
}
.menu-panel:not(:popover-open) { display: none; }
.menu-panel::backdrop { background: transparent; }

.menu-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  padding: 6px 10px 4px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--step-sm);
  font-weight: 500;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  transition: background 0.12s var(--ease);
}
.menu-item:hover { background: var(--surface-3); color: #ffffff; }
.menu-item svg { color: var(--muted); flex-shrink: 0; }
.menu-item:hover svg { color: #ffffff; }
.menu-item small { display: block; color: var(--muted); font-size: var(--step-xs); font-weight: 400; line-height: 1.3; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; border: 0; }

@supports (anchor-name: --a) {
  .menu-anchor { anchor-name: --menu-anchor; }
  .menu-panel {
    position-anchor: --menu-anchor;
    position-area: bottom span-left;
    justify-self: end;
    margin-top: 4px;
  }
}
@supports not (anchor-name: --a) {
  .menu-panel { top: 56px; right: var(--shell-pad); }
}

/* ==========================================================================
   CAMPOS DE FORMULÁRIO
   ========================================================================== */

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

select, .input {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 7px 10px;
  font-size: var(--step-sm);
  transition: border-color 0.12s var(--ease);
}
select { cursor: pointer; }
select:hover, .input:hover { border-color: var(--border-strong); }
select:focus, .input:focus {
  border-color: var(--accent);
  outline: none;
}

.field { margin-bottom: var(--space-3); }
.field label {
  display: block;
  font-size: var(--step-xs);
  color: var(--text-2);
  margin-bottom: 5px;
  font-weight: 600;
}
.field input, .field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  font-size: var(--step-sm);
  transition: border-color 0.12s var(--ease);
}
.field input:hover, .field select:hover { border-color: var(--border-strong); }
.field input:focus, .field select:focus {
  border-color: var(--accent);
  outline: none;
}
.field input::placeholder { color: var(--subtle); }
.field-hint { opacity: 0.75; font-weight: 400; font-size: 11px; }

/* Wrapper para input de senha com botão de toggle */
.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-input-wrap input { padding-right: 36px; }
.password-toggle-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
}
.password-toggle-btn:hover { color: var(--text); }

/* ==========================================================================
   CARDS DE MÉTRICA (KPIs) COM BARRAS SEMÂNTICAS CALIBRADAS
   ========================================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: var(--space-3);
}
@media(max-width: 1240px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat .label { min-height: 0; }
}
@media(max-width: 800px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media(max-width: 520px) { .stats { grid-template-columns: 1fr; } }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stat .accent-line {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}

.stat .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  font-weight: 700;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.stat .value {
  font-family: var(--font-family);
  font-size: clamp(20px, 1.8vw, 24px);
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  color: var(--text);
}
.stat .value span.unit {
  font-family: var(--font-family);
  font-size: var(--step-xs);
  color: var(--muted);
  font-weight: 600;
  margin-left: 4px;
}

.stat .sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   BARRA DE FERRAMENTAS & PRESETS
   ========================================================================== */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.presets-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.preset-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-right: 4px;
}
.preset-btn {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-family: inherit;
  font-size: var(--step-xs);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s var(--ease);
}
.preset-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.preset-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.35);
  font-weight: 700;
}
.preset-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.preset-btn.active .preset-badge {
  background: var(--accent);
  color: var(--on-accent);
}

.filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
  max-width: 400px;
}
.search svg.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 7px 32px 7px 32px;
  font-size: var(--step-sm);
  transition: border-color 0.12s var(--ease);
}
.search input:hover { border-color: var(--border-strong); }
.search input:focus {
  border-color: var(--accent);
  outline: none;
}
.search input::placeholder { color: var(--subtle); }

.search .search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  display: none;
  place-items: center;
  padding: 0;
}
.search .search-clear:hover { color: var(--text); }
.search input:not(:placeholder-shown) ~ .search-clear { display: grid; }

.filters select {
  max-width: 170px;
  min-width: 120px;
  flex: 0 1 auto;
}

.filter-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--step-xs);
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.filters .clear {
  margin-left: auto;
  font-size: var(--step-xs);
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: 1px solid transparent;
  font-family: inherit;
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  font-weight: 600;
}
.filters .clear:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }

/* Fichas de filtro ativo */
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chips:empty { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-xs);
  padding: 2px 6px 2px 8px;
  font-size: var(--step-xs);
  font-weight: 600;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.chip button:hover { opacity: 0.8; }

/* ==========================================================================
   LAYOUT PRINCIPAL & PAINÉIS
   ========================================================================== */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 3.3fr) minmax(280px, 1fr);
  gap: var(--space-4);
  align-items: start;
}
.grid > * { min-width: 0; }
@media(max-width: 1300px) {
  .grid { grid-template-columns: 1fr; }
}

.side-col { display: flex; flex-direction: column; gap: var(--space-4); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 14px;
}

.panel h2 {
  font-size: var(--step-sm);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}

.panel h2 .count {
  font-family: var(--font-family);
  color: var(--muted);
  font-weight: 600;
  font-size: var(--step-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  text-transform: none;
}

/* ==========================================================================
   TABELA CORPORATIVA COM CORES SEMÂNTICAS
   ========================================================================== */

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-sm);
}

thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 700;
  font-size: var(--step-eyebrow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  user-select: none;
}

thead th.sortable {
  cursor: pointer;
}
thead th.sortable:hover {
  color: var(--text);
  background: var(--surface-2);
}
thead th.sortable .sort-indicator {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
}
thead th.sortable.active {
  color: var(--accent);
}
thead th.sortable.active .sort-indicator {
  opacity: 1;
}

tbody td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover {
  background: var(--surface-hover);
}

tbody td:nth-child(4),
tbody td:nth-child(5),
tbody td:nth-child(6),
tbody td:nth-child(7) { white-space: nowrap; }

/* Código clicável */
.codigo {
  font-family: var(--font-family);
  font-weight: 700;
  font-size: var(--step-xs);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--accent-dim);
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.codigo:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: rgba(56, 189, 248, 0.45);
  color: #ffffff;
}

.tag { font-size: var(--step-xs); color: var(--muted); }

.uf {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface-3);
  border: 1px solid var(--border);
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  vertical-align: middle;
}

.obs {
  font-size: var(--step-xs);
  color: var(--warn-text);
  margin-top: 2px;
  font-style: italic;
}

.no-date {
  display: inline-block;
  font-size: var(--step-xs);
  color: var(--warn-text);
  background: var(--warn-dim);
  border: 1px solid rgba(227, 179, 65, 0.3);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--step-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}
.status-pill.aberta {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.status-pill.fechada {
  background: var(--ok-dim);
  color: var(--ok-text);
  border: 1px solid rgba(63, 185, 80, 0.3);
}
.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.cycle-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--purple-text);
  background: var(--purple-dim);
  border: 1px solid rgba(163, 113, 247, 0.3);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  margin-left: 4px;
  vertical-align: middle;
}

.row-actions { display: flex; gap: 4px; flex-wrap: nowrap; justify-content: flex-end; }

/* Barra de Envelhecimento (Aging) */
.aging { display: flex; flex-direction: column; gap: 4px; min-width: 100px; }
.aging .track {
  position: relative;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.aging .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: var(--radius-pill);
}
.aging .fill.blue { background: #38bdf8; }
.aging .fill.amber { background: #e3b341; }
.aging .fill.red { background: #f85149; }
.aging .days {
  font-size: var(--step-xs);
  color: var(--muted);
}
.aging .days b {
  color: var(--text);
  font-weight: 700;
}

/* Estado vazio */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  font-size: var(--step-sm);
  line-height: 1.5;
}
.empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 12px;
  color: var(--subtle);
}
.empty b {
  color: var(--text);
  display: block;
  font-size: var(--step-md);
  font-weight: 700;
  margin-bottom: 4px;
}

/* Responsividade mobile */
@media(max-width: 760px) {
  .table-scroll { overflow-x: visible; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  tbody td {
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    white-space: normal !important;
  }
  tbody tr td:last-child { border-bottom: none; }
  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
  }
  tbody td:last-child { grid-template-columns: 1fr; }
  tbody td:last-child::before { display: none; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; padding: 4px 0; }
  .codigo { max-width: 100%; }
  .aging { min-width: 0; }
}

/* ==========================================================================
   PAGINAÇÃO
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pagination:empty { display: none; }
.page-info {
  font-size: var(--step-xs);
  color: var(--muted);
}
.page-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-numbers { display: flex; gap: 4px; flex-wrap: wrap; }
.page-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: var(--step-xs);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover:not(:disabled) {
  background: var(--surface-3);
  color: #ffffff;
}
.page-btn.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-gap {
  color: var(--muted);
  padding: 0 4px;
  align-self: center;
}

/* ==========================================================================
   RESUMOS DA COLUNA LATERAL COM CORES VIVAS
   ========================================================================== */

.scroll-box { max-height: 340px; overflow-y: auto; padding-right: 4px; }

.resumo-head, .resumo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 38px 42px;
  align-items: center;
  gap: 6px;
}
.resumo-head {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.resumo-head span { text-align: right; }

.resumo-row {
  padding: 6px 4px;
  border-radius: var(--radius-xs);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.resumo-row:hover {
  background: var(--surface-2);
}
.resumo-row:last-child { border-bottom: none; }
.resumo-row.active {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.resumo-name {
  font-size: var(--step-sm);
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resumo-track { display: flex; gap: 2px; height: 4px; margin-top: 4px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-3); }
.resumo-fill { border-radius: var(--radius-pill); min-width: 0; }
.resumo-fill.aberta { background: #38bdf8; }
.resumo-fill.fechada { background: #3fb950; }

.resumo-n {
  font-size: var(--step-xs);
  text-align: right;
  font-weight: 700;
  align-self: start;
}
.resumo-n.aberta { color: #38bdf8; }
.resumo-n.fechada { color: #3fb950; }
.resumo-n.total { color: var(--text); font-weight: 700; }

/* Rotatividade */
.rot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  border-radius: var(--radius-xs);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  cursor: pointer;
}
.rot-item:hover { background: var(--surface-2); }
.rot-item:last-child { border-bottom: none; }
.rot-item .meta { min-width: 0; }
.rot-item .meta .cargo {
  font-size: var(--step-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.rot-item .meta .loc {
  font-size: var(--step-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rot-badge {
  font-size: var(--step-xs);
  font-weight: 800;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
}
.rot-badge.low {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.rot-badge.high {
  background: var(--purple-dim);
  color: var(--purple-text);
  border: 1px solid rgba(163, 113, 247, 0.3);
}

/* ==========================================================================
   MODAIS CORPORATIVOS
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(1, 4, 9, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 14px;
  font-size: var(--step-lg);
  font-weight: 800;
  color: var(--text);
}
.modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Histórico */
.hist-cycle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--step-sm);
}
.hist-cycle:last-child { border-bottom: none; }
.hist-cycle .dates { color: var(--text); }
.hist-cycle .dates .arrow { color: var(--muted); margin: 0 6px; }
.hist-cycle .dur {
  font-size: var(--step-xs);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.hist-cycle.current .dates { color: var(--accent); font-weight: 600; }

/* Modal de Confirmação */
.confirm-modal-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  background: var(--crit-dim);
  color: var(--crit-text);
  border: 1px solid rgba(248, 81, 73, 0.3);
}
.confirm-modal-icon.warn {
  background: var(--warn-dim);
  color: var(--warn-text);
  border-color: rgba(227, 179, 65, 0.3);
}

/* Modal de Exportação Personalizada */
.export-format-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
@media(max-width: 500px) {
  .export-format-grid { grid-template-columns: 1fr; }
}

.format-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.12s var(--ease);
}
.format-option:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.format-option.active {
  background: var(--surface-3);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.format-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.fmt-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  text-transform: uppercase;
}
.fmt-badge.excel { background: rgba(63, 185, 80, 0.18); color: #3fb950; border: 1px solid rgba(63, 185, 80, 0.3); }
.fmt-badge.pdf { background: rgba(248, 81, 73, 0.18); color: #f85149; border: 1px solid rgba(248, 81, 73, 0.3); }
.fmt-badge.csv { background: rgba(56, 189, 248, 0.18); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }

.format-option b { display: block; font-size: 13px; color: var(--text); line-height: 1.2; }
.format-option small { display: block; font-size: 10.5px; color: var(--muted); line-height: 1.2; margin-top: 2px; }

.export-scope-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px 14px;
}
.scope-radio-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--step-sm);
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.radio-label input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.radio-label b { color: var(--accent); }

.export-cols-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
}
@media(max-width: 500px) {
  .export-cols-grid { grid-template-columns: 1fr; }
}
.col-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--step-xs);
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.col-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.export-summary-box {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  font-size: var(--step-xs);
  color: var(--text-2);
  margin-top: 14px;
  line-height: 1.4;
}
.export-summary-box b { color: var(--text); }

/* ==========================================================================
   TOASTS
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--step-sm);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: auto;
  transition: all 0.15s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-icon { flex-shrink: 0; }
.toast.success .toast-icon { color: var(--ok-text); }
.toast.error .toast-icon { color: var(--crit-text); }
.toast.info .toast-icon { color: var(--accent); }

/* ==========================================================================
   TELA DE LOGIN
   ========================================================================== */

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 30px;
  box-shadow: var(--shadow-lg);
}

.auth-card .brand { justify-content: center; margin-bottom: 20px; }
.auth-card .brand .mark { width: 44px; height: 44px; font-size: 15px; }
.auth-card h1 {
  font-size: var(--step-lg);
  font-weight: 800;
  text-align: center;
  margin: 0 0 6px;
  color: var(--text);
}
.auth-card .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: var(--step-sm);
  margin: 0 0 24px;
  line-height: 1.45;
}

.auth-error {
  background: var(--crit-dim);
  color: var(--crit-text);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  font-size: var(--step-sm);
  margin-bottom: 18px;
  display: none;
  line-height: 1.4;
}
.auth-error.show { display: block; }

.auth-foot {
  text-align: center;
  margin-top: 20px;
  font-size: var(--step-xs);
  color: var(--muted);
  line-height: 1.5;
}

/* ==========================================================================
   TELA DE USUÁRIOS
   ========================================================================== */

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(163, 113, 247, 0.2));
  border: 1px solid var(--border-strong);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.user-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.users-table td, .users-table th { vertical-align: middle; }
.role-select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 5px 8px;
  font-size: var(--step-xs);
  font-weight: 600;
  cursor: pointer;
}
.role-select:hover { border-color: var(--border-strong); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--space-3);
}
@media(max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   RESPONSIVIDADE GERAL
   ========================================================================== */

@media(max-width: 900px) {
  .userbar .who .name { max-width: 120px; }
}

@media(max-width: 640px) {
  :root { --shell-pad: 16px; }
  .wrap { padding: 14px var(--shell-pad) 40px; }
  .top-inner { padding: 8px var(--shell-pad); gap: var(--space-2); }
  .brand p { display: none; }
  .brand .mark { width: 32px; height: 32px; font-size: 12px; }
  .search { max-width: none; flex-basis: 100%; }
  .filters { gap: 6px; }
  .filters select { flex: 1 1 130px; min-width: 0; }
  .filters .clear { margin-left: 0; }
  .panel { padding: 14px 12px; }
  .modal { padding: 20px 16px; }
  .pagination { justify-content: center; }
  .page-info { width: 100%; text-align: center; }
}
