/* ==========================================================================
   Chabra Dimensiona — identidade visual
   Cor primária institucional: #006B54
   ========================================================================== */

:root {
  --primary: #006B54;
  --primary-dark: #00523f;
  --primary-light: #e6f2ee;
  --primary-soft: #cfe6dd;

  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #1f2a26;
  --text-muted: #5f6b66;
  --border: #dfe5e2;

  --danger: #b3261e;
  --danger-dark: #8f1d17;
  --danger-bg: #fbe9e7;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 32, .06), 0 4px 12px rgba(16, 40, 32, .05);
  --sidebar-w: 268px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
em { font-style: normal; color: var(--primary-dark); font-weight: 500; }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .02em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 12px; opacity: .8; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 14px 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .88);
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-item:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nav-item.active { background: #fff; color: var(--primary); font-weight: 600; }

.badge {
  margin-left: auto;
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .badge { background: var(--primary-light); color: var(--primary); }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 18px;
  border-top: 1px solid rgba(255, 255, 255, .14);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer .hint { font-size: 12px; opacity: .78; padding: 0 4px 4px; line-height: 1.4; }
.version { font-size: 11px; opacity: .6; padding: 6px 4px 0; }

.content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 64px;
  max-width: none; /* ocupa toda a largura disponível (matriz de meses precisa de espaço) */
}

.page-header { margin-bottom: 22px; }
.page-header h1 { font-size: 26px; color: var(--primary-dark); }
.page-header p { color: var(--text-muted); margin-top: 6px; max-width: 64ch; }

/* --------------------------------------------------------------------------
   Cards, stats
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.card h2 { font-size: 16px; margin-bottom: 14px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.card-head h2 { margin-bottom: 0; }
.card-head .right { display: flex; align-items: center; gap: 10px; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  flex: 1;
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.stat .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 22px; font-weight: 700; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-muted); margin-left: 2px; }

.note {
  font-size: 13px;
  color: var(--text-muted);
  background: #fbfcfb;
  border: 1px dashed var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 14px;
}

.muted { color: var(--text-muted); font-size: 13px; }

/* --------------------------------------------------------------------------
   Formulários
   -------------------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: start;
}
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.field small { font-size: 12px; color: var(--text-muted); line-height: 1.35; }

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 107, 84, .15); }
.input-sm { padding: 6px 10px; }
.input-num { width: 120px; text-align: right; font-variant-numeric: tabular-nums; }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 2px;
}

/* --------------------------------------------------------------------------
   Botões
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

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

.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

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

.btn-outline-light { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.btn-outline-light:hover { background: rgba(255, 255, 255, .12); border-color: #fff; }
.btn-outline-light:focus-visible { outline-color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

.btn-link {
  background: none;
  border: 0;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--primary);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}
.btn-link:hover { background: var(--primary-light); }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { background: var(--danger-bg); }

/* --------------------------------------------------------------------------
   Tabelas
   -------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  font-weight: 600;
  background: #fafbfa;
  white-space: nowrap;
}
.table tbody tr:hover { background: #f7faf9; }
.table tbody tr.editing { background: var(--primary-light); }
.table tfoot th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 14px;
  border-bottom: 0;
}
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table td.actions .btn-link + .btn-link { margin-left: 4px; }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip-green { background: var(--primary-light); color: var(--primary-dark); }
.chip-gray { background: #eef1f0; color: var(--text-muted); }
.chip-blue { background: #e7eef8; color: #2b4c7e; }

.saved-flag { font-size: 12px; color: var(--primary); margin-left: 8px; opacity: 0; transition: opacity .3s; }
.saved-flag.show { opacity: 1; }

.empty { text-align: center; padding: 36px 16px; color: var(--text-muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; font-weight: 600; }
.empty .btn { margin-top: 14px; }

/* --------------------------------------------------------------------------
   Toast e diálogo
   -------------------------------------------------------------------------- */

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: #1f2a26;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  font-size: 14px;
  max-width: 360px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left: 4px solid #3ddc97; }
.toast-error { border-left: 4px solid #ff6b6b; }
.toast-info { border-left: 4px solid #ffd166; }

.dialog {
  border: 0;
  border-radius: 12px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  color: var(--text);
}
.dialog::backdrop { background: rgba(16, 40, 32, .45); }
.dialog form { padding: 22px 24px; }
.dialog h3 { font-size: 17px; margin-bottom: 8px; }
.dialog p { color: var(--text-muted); white-space: pre-line; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* --------------------------------------------------------------------------
   Responsivo
   -------------------------------------------------------------------------- */

@media (max-width: 1000px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px 12px; }
  .nav-item { width: auto; flex-shrink: 0; }
  .badge { margin-left: 4px; }
  .sidebar-footer { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .sidebar-footer .hint, .version { display: none; }
  .content { padding: 20px 16px 48px; }
}

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-header h1 { font-size: 22px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
}

/* --------------------------------------------------------------------------
   Telas de estado (carregando / login / configuração / erro)
   -------------------------------------------------------------------------- */

.screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
}
.screen-box { text-align: center; }
.screen-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(16, 40, 32, .10);
  padding: 28px 28px 30px;
}
.screen-card h1 { font-size: 22px; color: var(--primary-dark); margin: 18px 0 6px; }
.screen-card .muted { margin-bottom: 8px; line-height: 1.5; }
.screen-card code { font-size: 13px; background: var(--primary-light); color: var(--primary-dark); padding: 1px 6px; border-radius: 4px; }
.screen-card .btn { margin-top: 14px; }

.brand-light { padding: 0; border: 0; color: var(--text); }
.brand-light .brand-mark { background: var(--primary); color: #fff; }
.brand-light .brand-sub { color: var(--text-muted); opacity: 1; }

.form-stack { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.btn-block { width: 100%; }
.form-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.4;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

form.busy { opacity: .7; pointer-events: none; }

/* usuário logado (rodapé da sidebar) */
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 4px 0;
  font-size: 13px;
}
.user-email { opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.btn-link.light { color: #fff; opacity: .9; flex-shrink: 0; }
.btn-link.light:hover { background: rgba(255, 255, 255, .14); opacity: 1; }

@media (max-width: 820px) {
  .user-row { padding: 0; }
}

/* --------------------------------------------------------------------------
   Usuários / senha
   -------------------------------------------------------------------------- */

.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }

.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  padding-top: 6px;
}
.field-check input { width: 16px; height: 16px; accent-color: var(--primary); }

.user-actions { display: flex; gap: 2px; flex-shrink: 0; }

.btn-link:disabled { opacity: .4; cursor: not-allowed; }
.btn-link:disabled:hover { background: none; }

.dialog .form-stack { margin-top: 14px; }
.dialog .form-stack .field-check { padding-top: 0; }

/* --------------------------------------------------------------------------
   Fase 2 — programação / status / calendário
   -------------------------------------------------------------------------- */

.nav-section {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .6;
  padding: 10px 12px 4px;
}
.nav-section:first-child { padding-top: 0; }

.barra-params {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}
.param { display: flex; flex-direction: column; gap: 5px; }
.param-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.param-inline { display: flex; align-items: center; gap: 8px; }
.param select.input-sm { width: auto; min-width: 120px; }
.input-pct { width: 80px; }

.stat-wide { flex: 2; min-width: 260px; }
.stat .value.neg { color: var(--danger); }
.stat .value-status { font-size: 15px; padding-top: 4px; }

.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status-ok      { background: #dff3ea; color: #0b5d43; }
.status-atencao { background: #fff1cc; color: #7a5200; }
.status-deficit { background: #fde2df; color: #8f1d17; }

.table tbody tr.row-ok      { background: #f3faf7; }
.table tbody tr.row-atencao { background: #fff9e8; }
.table tbody tr.row-deficit { background: #fdf1ef; }
.table tbody tr.row-ok:hover      { background: #eaf5ef; }
.table tbody tr.row-atencao:hover { background: #fff3d6; }
.table tbody tr.row-deficit:hover { background: #fbe6e3; }
.table tfoot tr.row-deficit th { background: #fde2df; color: #8f1d17; }
.table tfoot tr.row-atencao th { background: #fff1cc; color: #7a5200; }
.table tbody tr.row-total td { font-weight: 600; background: var(--primary-light); }

.cel-ok      { color: #0b5d43; }
.cel-atencao { color: #7a5200; background: #fff9e8; }
.cel-deficit { color: #8f1d17; background: #fdf1ef; font-weight: 600; }

.table-grade th, .table-grade td { padding: 8px 8px; font-size: 13px; }
.table-prog .th-group { text-align: center; border-bottom: 0; }
.table-prog thead tr.sub th { padding-top: 4px; }

.rec { font-weight: 600; font-size: 13px; }
.rec-contratar { color: #8f1d17; }
.rec-ocioso    { color: #7a5200; }
.rec-adequado  { color: #0b5d43; }

.legenda { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; font-size: 12px; color: var(--text-muted); align-items: center; }
.legenda > span { display: inline-flex; align-items: center; gap: 6px; }

.alert { border-radius: 8px; padding: 12px 14px; font-size: 13px; margin-bottom: 20px; line-height: 1.5; }
.alert-warn { background: #fff8e1; border: 1px solid #f3dd9a; color: #6b4a00; }
.alert ul { margin: 0; padding-left: 18px; }

.chip-warn { background: #fff1cc; color: #7a5200; }

.barra-col { width: 30%; }
.barra { height: 8px; background: var(--primary-light); border-radius: 999px; overflow: hidden; }
.barra-fill { height: 100%; background: var(--primary); border-radius: 999px; }

.fatores { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; }
.fatores .field { min-width: 120px; }
.fatores .saved-flag { align-self: center; }

.calendario-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px 14px;
}
.cal-mes .input-num { width: 100%; text-align: center; }

@media (max-width: 1000px) {
  .calendario-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .calendario-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .barra-params { gap: 12px; }
}

/* editor de alocação por unidade (Colaboradores) */
.alocacoes { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: #fff; }
.aloc-linha { display: flex; align-items: center; gap: 10px; padding: 6px 2px; cursor: pointer; }
.aloc-linha + .aloc-linha { border-top: 1px solid var(--border); }
.aloc-linha input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.aloc-nome { flex: 1; min-width: 0; }
.aloc-pct { display: flex; align-items: center; gap: 6px; }
.aloc-pct .input-num { width: 80px; }
.aloc-rodape { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px 2px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.aloc-aviso { color: var(--text-muted); }
.aloc-aviso.erro { color: var(--danger); font-weight: 600; }

/* variação mensal de empresas */
.table-mes .input-mes { width: 90px; }
.table-mes .input-mes::placeholder { color: #a5b0ab; }
.table-mes tbody tr.mes-excecao { background: #eef4fb; }
.table-mes tbody tr.mes-excecao:hover { background: #e4edf8; }
.table-mes tbody tr.mes-excecao .input-mes { border-color: #9db8dc; font-weight: 600; }

/* --------------------------------------------------------------------------
   Linguagem simples: cartões de programação, sinais, matriz de empresas
   -------------------------------------------------------------------------- */

.param-ajuda {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary-dark); font-size: 12px; font-weight: 700; cursor: help;
}

.grade-cartoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; margin-bottom: 20px; }
.cartao-unidade { margin-bottom: 0; border-left: 5px solid var(--border); }
.cartao-unidade.row-ok      { border-left-color: #2e9e6e; background: #fff; }
.cartao-unidade.row-atencao { border-left-color: #e0a800; background: #fff; }
.cartao-unidade.row-deficit { border-left-color: #d0413a; background: #fff; }
.cartao-unidade .card-head { align-items: flex-start; }
.cartao-unidade .card-head h2 { margin-bottom: 2px; }

.blocos-funcao { display: grid; grid-template-columns: 1fr; gap: 10px; }
.bloco-funcao { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fafbfa; }
.bloco-funcao.row-ok      { background: #f3faf7; border-color: #cfe9dc; }
.bloco-funcao.row-atencao { background: #fff9e8; border-color: #f3e2a8; }
.bloco-funcao.row-deficit { background: #fdf1ef; border-color: #f2c9c5; }
.bloco-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.bloco-head .status { margin-left: auto; }
.frases { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.55; }
.frases li + li { margin-top: 2px; }
.rec-linha { margin-top: 8px; font-size: 14px; }
.rec-contratar { color: #8f1d17; }
.rec-limite    { color: #7a5200; }
.rec-folga, .rec-adequado { color: #0b5d43; }
.frases-resumo { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }

.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; }
.dot-ok      { background: #2e9e6e; }
.dot-atencao { background: #e0a800; }
.dot-deficit { background: #d0413a; }

.table-prog td small { color: var(--text-muted); font-size: 12px; }
.table-prog th[rowspan] { vertical-align: bottom; }

/* matriz unidade × mês */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg-btn { border: 0; background: #fff; padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--text-muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.ativo { background: var(--primary); color: #fff; font-weight: 600; }
.table-matriz th, .table-matriz td { padding: 6px 6px; font-size: 13px; }
.table-matriz .col-nome { white-space: nowrap; font-weight: 500; }
.table-matriz .col-padrao { background: var(--primary-light); }
.table-matriz { table-layout: auto; }
.table-matriz th, .table-matriz td { padding: 5px 3px; font-size: 12.5px; }
.table-matriz .input-padrao, .table-matriz .input-mes { width: 100%; min-width: 52px; padding: 3px 4px; text-align: center; font-size: 12.5px; }
.table-matriz th.num, .table-matriz td.num { width: 6.2%; }
.table-matriz td.actions .btn-link { font-size: 12px; padding: 2px 6px; }
.table-matriz .input-mes::placeholder { color: #b5bfba; }
.table-matriz td.cel-excecao { background: #eef4fb; }
.table-matriz td.cel-excecao .input-mes { border-color: #9db8dc; font-weight: 600; }
.table-matriz .col-media { font-weight: 600; }

/* telas de notebook (≤1440px): menos margem lateral para a matriz de meses caber inteira */
@media (max-width: 1440px) and (min-width: 821px) {
  .content { padding: 24px 24px 48px; }
  .table-matriz .input-padrao, .table-matriz .input-mes { min-width: 48px; }
}

/* matriz: centralização e linhas por grau */
.table-matriz th, .table-matriz td { text-align: center; vertical-align: middle; }
.table-matriz th.col-nome, .table-matriz td.col-nome, .table-matriz th.col-grau, .table-matriz td.col-grau { text-align: left; }
.table-matriz td.col-nome { vertical-align: top; padding-top: 10px; background: #fff; border-right: 1px solid var(--border); }
.table-matriz .nome-unidade { font-weight: 600; }
.table-matriz .acoes-unidade { margin-top: 4px; }
.table-matriz .acoes-unidade .btn-link { font-size: 12px; padding: 2px 4px; }
.table-matriz .col-grau { white-space: nowrap; }
.table-matriz .col-padrao { background: var(--primary-light); }
.table-matriz tr.linha-total-unidade td { background: #f3f6f4; border-bottom: 2px solid #cfd8d3; }
.table-matriz tfoot th { text-align: center; }
.table-matriz tfoot th.col-nome { text-align: left; }
.chip-grau { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.sit-em-dia   { background: #e3f2ea; color: #0b5d43; }
.sit-vencendo { background: #fff1cc; color: #7a5200; }
.sit-a-vencer { background: #fde2df; color: #8f1d17; }

.input-sufixo { white-space: nowrap; align-self: center; }

/* histórico */
.hist-dia { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); margin: 14px 0 6px; }
.hist-dia:first-child { margin-top: 0; }
.hist-item { display: grid; grid-template-columns: 52px 160px 1fr; gap: 10px; padding: 7px 8px; border-left: 3px solid var(--border); border-radius: 4px; font-size: 14px; line-height: 1.45; }
.hist-item + .hist-item { margin-top: 3px; }
.hist-insert { border-left-color: #2e9e6e; background: #f6fbf8; }
.hist-update { border-left-color: #3b6fb6; background: #f5f8fc; }
.hist-delete { border-left-color: #d0413a; background: #fdf4f3; }
.hist-importacao { border-left-color: #7a5200; background: #fff9e8; }
.hist-hora { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hist-quem { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-frase s { color: var(--text-muted); }
.hist-rodape { text-align: center; margin-top: 12px; }
@media (max-width: 700px) { .hist-item { grid-template-columns: 52px 1fr; } .hist-quem { grid-column: 2; } .hist-frase { grid-column: 1 / -1; } }

/* filtros de lista */
.filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filtros .input-sm { width: auto; min-width: 160px; }
.filtros .filtro-texto { min-width: 220px; flex: 1; max-width: 360px; }

/* colaboradores: unidades e tempo em colunas separadas, linha a linha */
.col-unidades div, .col-tempo div { line-height: 1.6; white-space: nowrap; }
.col-tempo { font-variant-numeric: tabular-nums; }

/* funções / chefia */
.chip-chefia { background: #4a2c80; color: #fff; }
.alocacoes.sem-pct .aloc-pct, .alocacoes.sem-pct .aloc-rodape { display: none; }
.ajuda-sem-pct { display: none; }
.alocacoes.sem-pct + .ajuda-pct { display: none; }
.alocacoes.sem-pct + .ajuda-pct + .ajuda-sem-pct { display: block; }
.linha-chefia { margin-top: 4px; font-size: 13px; }
.linha-chefia .chefia-vazia { color: var(--text-muted); }
.tipo-opcoes { display: grid; gap: 8px; }
.tipo-opcao { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.tipo-opcao:has(input:checked) { border-color: var(--primary); background: #f2f8f5; }
.tipo-opcao input { margin-top: 3px; }
.tipo-opcao small { display: block; color: var(--text-muted); }
.check-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }

/* alternância de modo no cabeçalho */
.page-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); flex-shrink: 0; }
.segmented button { padding: 8px 16px; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-weight: 500; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button:hover { background: var(--primary-light); color: var(--primary-dark); }
.segmented button.ativo { background: var(--primary); color: #fff; }

/* organograma */
.org-wrap { overflow-x: auto; padding: 4px 0 12px; margin: 0 -22px; padding-left: 22px; padding-right: 22px; }
.org-tree, .org-tree ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; position: relative; }
.org-tree { width: max-content; min-width: 100%; }
.org-tree ul { padding-top: 24px; }
.org-tree ul::before { content: ''; position: absolute; top: 0; left: 50%; height: 24px; border-left: 2px solid var(--primary-soft); }
.org-tree li { display: flex; flex-direction: column; align-items: center; position: relative; padding: 24px 8px 0; }
.org-tree > li { padding-top: 0; }
.org-tree li::before, .org-tree li::after { content: ''; position: absolute; top: 0; right: 50%; width: 50%; height: 24px; border-top: 2px solid var(--primary-soft); }
.org-tree li::after { right: auto; left: 50%; border-left: 2px solid var(--primary-soft); }
.org-tree > li::before, .org-tree > li::after, .org-tree li:only-child::before, .org-tree li:only-child::after { display: none; }
.org-tree li:only-child { padding-top: 24px; }
.org-tree > li:only-child { padding-top: 0; }
.org-tree li:first-child::before, .org-tree li:last-child::after { border: 0 none; }
.org-tree li:last-child::before { border-right: 2px solid var(--primary-soft); border-radius: 0 8px 0 0; }
.org-tree li:first-child::after { border-radius: 8px 0 0 0; }
.org-node { width: 236px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; text-align: left; }
.org-root { border-color: var(--primary); border-top: 4px solid var(--primary); }
.org-unidade { border-top: 4px solid var(--primary-soft); }
.org-sem-unidade { border: 1px dashed #d9b64a; border-top: 4px solid #d9b64a; background: #fffdf5; }
.org-node-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.org-node-head strong { font-size: 14px; color: var(--primary-dark); }
.org-secao { border-top: 1px solid var(--border); padding: 8px 0 4px; }
.org-secao-titulo { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 4px; }
.org-secao-chefia .org-secao-titulo { color: #4a2c80; }
.org-pessoa { display: flex; flex-direction: column; text-align: left; background: transparent; border: 0; border-radius: 6px; padding: 5px 6px; margin: 0 -6px; width: calc(100% + 12px); cursor: pointer; font: inherit; color: var(--text); }
.org-pessoa:hover { background: var(--primary-light); }
.org-nome { font-size: 13px; font-weight: 500; }
.org-funcao { font-size: 11.5px; color: var(--text-muted); }

.org-estrela { color: #4a2c80; font-size: 11px; }
.org-chefe { border-top: 4px solid #4a2c80; }
.org-chefe .org-pessoa { margin: -4px -6px 0; }
.org-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; border-top: 1px solid var(--border); padding-top: 6px; }
.org-meta .org-alerta { color: #8a5a00; font-weight: 600; }
.org-equipes { width: 224px; padding: 6px 12px 8px; }
.org-equipe { padding: 8px 0 4px; }
.org-equipe + .org-equipe { border-top: 1px solid var(--border); }
.org-equipe-titulo { font-size: 12.5px; margin-bottom: 2px; }
.org-equipe-titulo strong { color: var(--primary-dark); }
.org-grupo-rotulo { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 4px 0 2px; }
.org-sem-chefia { border: 1px dashed #d9b64a; border-top: 4px solid #d9b64a; background: #fffdf5; }
.org-sem-chefia .org-node-head { margin-bottom: 2px; }
.org-vazio { display: block; font-size: 12px; color: var(--text-muted); font-style: italic; padding: 2px 0; }

/* barras de pessoas por unidade */
.org-barras { display: grid; gap: 8px; }
.org-barra-linha { display: grid; grid-template-columns: minmax(120px, 200px) 1fr 64px; align-items: center; gap: 12px; }
.org-barra-nome { font-size: 13px; font-weight: 500; }
.org-barra { display: flex; height: 18px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.org-barra-seg { display: block; height: 100%; }
.seg-tec { background: var(--primary); }
.seg-adm { background: #2b4c7e; }
.org-barra-total small { color: #4a2c80; font-size: 11px; margin-left: 4px; }
.org-barra-total { text-align: right; font-variant-numeric: tabular-nums; }
.org-legenda { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 4px; }
.org-legenda span { display: inline-flex; align-items: center; gap: 6px; }
.org-legenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.org-dica { margin: -6px 0 10px; }

/* impressão do organograma: só a árvore, em folha deitada */
.print-only { display: none; }
@media print {
  body.imprimindo-organograma { background: #fff; }
  body.imprimindo-organograma .sidebar,
  body.imprimindo-organograma .page-header,
  body.imprimindo-organograma .stats,
  body.imprimindo-organograma .card:not(.card-organograma),
  body.imprimindo-organograma .card-organograma .card-head,
  body.imprimindo-organograma .org-dica,
  body.imprimindo-organograma #toast-container { display: none !important; }
  body.imprimindo-organograma .content { padding: 0; }
  body.imprimindo-organograma .card-organograma { border: 0; box-shadow: none; padding: 0; margin: 0; }
  body.imprimindo-organograma .print-only { display: block; }
  body.imprimindo-organograma .print-cabecalho { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--primary); padding-bottom: 6px; margin-bottom: 10px; }
  body.imprimindo-organograma .print-cabecalho strong { font-size: 16px; color: var(--primary-dark); }
  body.imprimindo-organograma .print-cabecalho span { font-size: 11px; color: var(--text-muted); }
  body.imprimindo-organograma .org-wrap { overflow: visible; margin: 0; padding: 0; }
  body.imprimindo-organograma .org-tree { min-width: 0; width: max-content; margin: 0 auto; }
  body.imprimindo-organograma .org-node { box-shadow: none; break-inside: avoid; }
  body.imprimindo-organograma .org-pessoa { cursor: default; }
  body.imprimindo-organograma .org-tree li::before, body.imprimindo-organograma .org-tree li::after, body.imprimindo-organograma .org-tree ul::before { border-color: #9bb8ad; }
  body.imprimindo-organograma * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-orientacao { display: inline-flex; align-items: center; gap: 6px; }
.print-orientacao .input-sm { width: auto; padding-top: 4px; padding-bottom: 4px; }
