/* ═══════════════════════════════════════════
   PROMAD · Sistema de Gestão — CSS Principal
   Tema: Branco/Claro com verde PROMAD/AMAC
   e amarelo dourado como destaque
═══════════════════════════════════════════ */

:root {
  /* Verdes institucionais AMAC/PROMAD */
  --g1:  #f0f7f2;
  --g2:  #d6ead9;
  --g3:  #4a9b5f;
  --g4:  #2d7a45;
  --g5:  #2d3748;
  --g6:  #2d3748;
  --g7:  #1a202c;
  --gd:  #F5C518;   /* Amarelo logo PROMAD */

  /* Superfícies */
  --bg:      #f5f6f7;
  --card-bg: #ffffff;
  --card2:   #ffffff;
  --borda:   #e2e8e4;
  --borda2:  #d0d9d3;

  /* Texto */
  --ink:  #1a2e20;
  --mu:   #6b7f72;
  --i2:   #4a5c50;

  /* Sidebar */
  --sb-bg:    #2d3748;
  --sb-hover: rgba(255,255,255,.07);
  --sb-on:    rgba(245,197,24,.18);

  /* Amarelo */
  --amarelo:  #F5C518;
  --amarelo2: #d4a800;
  --am-soft:  rgba(245,197,24,.12);

  /* Botões */
  --btn-p-bg:  #F5C518;
  --btn-p-txt: #1a2e20;

  /* Status */
  --ba: #16a34a; --bi: #6b7280;
  --bp: #d97706; --be: #dc2626;
  --bv: #2563eb; --rd: #dc2626;
  --er: #dc2626;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* ════════════════════════════
   SIDEBAR cinza
════════════════════════════ */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: #2d3748;
  border-right: 1px solid rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
}
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }

/* Brand */
.sb-brand {
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sb-logo-img {
  width: 100%;
  max-width: 150px;
  height: auto;
  display: block;
  margin-bottom: 2px;
}
.sb-sub {
  font-size: .rem;
  color: rgba(255,255,255,255);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
}

/* Seções */
.sb-sec {
  font-size: .57rem;
  font-weight: 700;
  color: rgba(255,255,255,255);
  text-transform: uppercase;
  letter-spacing: 1.8px;
  padding: 16px 18px 4px;
}

/* Itens */
.sbi {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  cursor: pointer;
  color: rgba(255,255,255,255);
  font-size: .84rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  user-select: none;
}
.sbi:hover { background: var(--sb-hover); color: rgba(255,255,255,.9); }
.sbi.on {
  background: rgba(245,197,24,.15);
  color: var(--amarelo);
  border-left-color: var(--amarelo);
  font-weight: 700;
}
.sbi span:first-child { font-size: 1rem; flex-shrink: 0; }

.sb-cnt {
  margin-left: auto;
  background: rgba(245,197,24,.18);
  color: var(--amarelo);
  font-size: .64rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}

/* Usuário logado */
.sb-user {
  margin: 10px 14px 0;
  padding: 11px 13px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 9px;
}
.sb-user-nome {
  font-size: .82rem;
  font-weight: 700;
  color: var(--amarelo);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-user-perfil {
  font-size: .67rem;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 1px;
}

.sb-foot {
  margin-top: auto;
  padding: 12px 18px;
  font-size: .61rem;
  color: rgba(255,255,255,.2);
  line-height: 1.7;
  border-top: 1px solid rgba(255,255,255,.07);
}

/* ════════════════════════════
   LAYOUT PRINCIPAL
════════════════════════════ */
.main { 
   flex: 1; 
   display: flex;
   flex-direction: column;
   overflow: hidden;
   min-width: 0;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--borda);
  padding: 0 26px;
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.tcrumb { font-size: .82rem; color: var(--mu); }
.tcrumb strong { color: var(--ink); font-weight: 700; }
.tbadge {
  font-size: .7rem;
  font-weight: 700;
  background: rgba(45,55,72,.08);
  color: #2d3748;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(45,55,72,.15);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.content { flex: 1; overflow-y: auto; padding: 24px 26px; position: relative; z-index: 1; min-height: 0; }
.page { display: none; }
.page.on { display: block; }

.ph { margin-bottom: 22px; display: block; width: 100%; }
.ph h1 { font-size: 1.45rem; font-weight: 800; color: var(--ink); letter-spacing: -.3px; display: block; }
.ph p  { font-size: .82rem; color: var(--mu); margin-top: 3px; }

/* ════════════════════════════
   KPI CARDS
════════════════════════════ */
.krow { display: flex; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.kpi {
  flex: 1; min-width: 150px;
  background: #ffffff;
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 18px 20px;
  border-top: 3px solid var(--g4);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  transition: box-shadow .2s, transform .15s;
}
.kpi:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-1px); }
.kpi.g  { border-top-color: #2d3748; }
.kpi.go { border-top-color: var(--amarelo); }
.kpi.am { border-top-color: #d97706; }
.kpi.gr { border-top-color: #7c3aed; }
.kpi.az { border-top-color: #2563eb; }
.kpi.tl { border-top-color: #0d9488; }
.kpi.on { box-shadow: 0 4px 14px rgba(0,0,0,.12); transform: translateY(-2px); background: #fafafa; }
.kl { font-size: .7rem; font-weight: 700; color: var(--mu); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px; }
.kv { font-size: 2rem; font-weight: 800; color: #2d3748; line-height: 1; }
.ks { font-size: .72rem; color: var(--mu); margin-top: 5px; }

/* ════════════════════════════
   CARDS / TABELAS
════════════════════════════ */
.card {
  background: #ffffff;
  border: 1px solid var(--borda);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.chd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--borda);
  background: #fafbfa;
}
.cttl { font-size: .9rem; font-weight: 700; color: var(--ink); }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f4f6f8;
  padding: 10px 14px;
  text-align: left;
  font-size: .67rem;
  font-weight: 700;
  color: #4a5568;
  text-transform: uppercase;
  letter-spacing: .8px;
  border-bottom: 1px solid var(--borda);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f0f4f1; transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f9fbf9; }
td { padding: 11px 14px; font-size: .84rem; color: var(--ink); vertical-align: middle; }
tfoot td { padding: 10px 14px; border-top: 1px solid var(--borda); background: #f8faf8; }

.empty { padding: 40px 20px; text-align: center; color: var(--mu); }
.ei { font-size: 2rem; margin-bottom: 10px; opacity: .35; }
.empty p { font-size: .84rem; }

.dg { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .dg { grid-template-columns: 1fr; } }
.cbp { padding: 12px 0; max-height: 220px; overflow-y: auto; }

/* ════════════════════════════
   TOOLBAR / FILTROS
════════════════════════════ */
.tb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.sw {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1.5px solid var(--borda);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1;
  max-width: 340px;
  transition: border-color .2s, box-shadow .2s;
}
.sw:focus-within {
  border-color: #F5C518;
  box-shadow: 0 0 0 3px rgba(245,197,24,.12);
}
.sw input { border: none; outline: none; background: transparent; font-size: .85rem; flex: 1; color: var(--ink); }
.sw input::placeholder { color: #aab; }
.si { color: var(--mu); font-size: .9rem; }

.fps { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.pill {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--borda2);
  color: var(--mu);
  background: #ffffff;
  transition: all .15s;
  user-select: none;
}
.pill:hover { border-color: #2d3748; color: #2d3748; }
.pill.on { background: #2d3748; color: #ffffff; border-color: #2d3748; font-weight: 700; }

/* ════════════════════════════
   BOTÕES
════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Primário — amarelo PROMAD */
.btn-p {
  background: #F5C518;
  color: #1a2e20;
  box-shadow: 0 2px 6px rgba(245,197,24,.25);
  font-weight: 800;
}
.btn-p:hover {
  background: #d4a800;
  box-shadow: 0 4px 12px rgba(245,197,24,.4);
}

/* Secundário — cinza claro */
.btn-s {
  background: #f1f4f2;
  color: var(--i2);
  border: 1px solid var(--borda2);
}
.btn-s:hover { background: #e6ebe7; color: var(--ink); }

/* Destrutivo */
.btn-d {
  background: #fff1f1;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.btn-d:hover { background: #ffe4e4; }

.btn-sm { padding: 5px 10px; font-size: .75rem; border-radius: 6px; }
.btn-ic { padding: 5px 8px; }
.ag { display: flex; gap: 5px; align-items: center; }

/* ════════════════════════════
   BADGES
════════════════════════════ */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .71rem;
  font-weight: 700;
  letter-spacing: .2px;
}
.ba { background: #dcfce7; color: #15803d; }
.bi { background: #f3f4f6; color: #6b7280; }
.bp { background: #fef3c7; color: #92400e; }
.be { background: #fee2e2; color: #dc2626; }
.bv { background: #dbeafe; color: #1d4ed8; }
.am { background: #fef9c3; color: #854d0e; }

/* ════════════════════════════
   ALERTAS
════════════════════════════ */
.alrt {
  display: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
}
.alrt.ok { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.alrt.er { background: #fff1f1; color: #dc2626; border: 1px solid #fecaca; }

/* ════════════════════════════
   MODAIS
════════════════════════════ */
.ov {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  z-index: 1200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ov.open { display: flex; }

.modal {
  background: #ffffff;
  border: 1px solid var(--borda);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}
.modal-sm { max-width: 480px; }

.mhd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--borda);
  background: #fafbfa;
  border-radius: 14px 14px 0 0;
  flex-shrink: 0;
}
.mttl { font-size: 1rem; font-weight: 800; color: var(--ink); }
.mcl {
  background: #f1f4f2;
  border: 1px solid var(--borda2);
  color: var(--mu);
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.mcl:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }

.mbdy { flex: 1; overflow-y: auto; padding: 20px; }
.mft {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--borda);
  background: #fafbfa;
  border-radius: 0 0 14px 14px;
  flex-shrink: 0;
}

/* Formulários */
.fsec {
  font-size: .68rem;
  font-weight: 800;
  color: #2d3748;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e2e8f0;
}
.fsec:first-child { margin-top: 0; }

.fg  { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fg3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld.ff { grid-column: 1 / -1; }

.fld label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--mu);
  text-transform: uppercase;
  letter-spacing: .8px;
}
.fld input,
.fld select,
.fld textarea {
  background: #ffffff;
  border: 1.5px solid var(--borda2);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: .85rem;
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.fld input:focus,
.fld select:focus,
.fld textarea:focus {
  border-color: #F5C518;
  box-shadow: 0 0 0 3px rgba(245,197,24,.12);
}
.fld input::placeholder,
.fld textarea::placeholder { color: #bbc; }
.fld select { cursor: pointer; }
.fld textarea { resize: vertical; min-height: 72px; }

.req { color: var(--rd); margin-left: 2px; }
.field-hint { font-size:.68rem; color:var(--mu); margin-left:5px; font-weight:400; }

/* ════════════════════════════
   DRAWER (FICHA)
════════════════════════════ */
.dov {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
  z-index: 1100;
}
.dov.open { display: block; }

.drawer {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 640px;
  max-width: 95vw;
  background: #ffffff;
  border-left: 1px solid var(--borda);
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(0,0,0,.12);
}
.dhd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--borda);
  background: #fafbfa;
  flex-shrink: 0;
}
.dhd h2 { font-size: 1.05rem; font-weight: 800; color: var(--ink); }
.dcl {
  background: #f1f4f2;
  border: 1px solid var(--borda2);
  color: var(--mu);
  width: 32px; height: 32px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.dcl:hover { background: #fee2e2; color: #dc2626; }

.dbdy { flex: 1; overflow-y: auto; padding: 18px 20px; background: #fafbfa; }
.dft {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--borda);
  background: #ffffff;
  flex-shrink: 0;
}

.ds { margin-bottom: 18px; }
.dst {
  font-size: .68rem;
  font-weight: 800;
  color: #2d3748;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #e2e8f0;
}
.dg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.di {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px;
  background: #ffffff;
  border-radius: 7px;
  border: 1px solid var(--borda);
}
.di.full { grid-column: 1/-1; }
.di label { font-size: .63rem; font-weight: 700; color: var(--mu); text-transform: uppercase; letter-spacing: .6px; }
.di span  { font-size: .83rem; color: var(--ink); font-weight: 500; }

table.ct { font-size: .78rem; }
table.ct thead th { padding: 7px 10px; }
table.ct td { padding: 7px 10px; }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: #d1d9d4 transparent; }
*::-webkit-scrollbar { width: 5px; height: 5px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #d1d9d4; border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: #b0bdb5; }

/* ════════════════════════════
   RESPONSIVIDADE
════════════════════════════ */

/* Botão hambúrguer — oculto no desktop */
.sb-toggle {
  display: none;
  background: none;
  border: 1px solid var(--borda2);
  border-radius: 7px;
  cursor: pointer;
  padding: 5px 9px;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.sb-toggle:hover { background: var(--g1); }

/* Overlay da sidebar no mobile */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sb-overlay.open { display: block; }

/* Wrapper de tabela com scroll horizontal (dentro de .card) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Tablet: 1024px ── */
@media (max-width: 1024px) {
  /* Sidebar vira drawer deslizante */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,.22);
  }
  .sb-toggle { display: inline-flex; }
  .main { width: 100%; }
  .content { padding: 18px 18px; }

  /* KPI wrap */
  .kpi { min-width: 160px; }

  /* Topbar */
  .topbar { padding: 0 18px; }
}

/* ── Mobile: 640px ── */
@media (max-width: 640px) {
  .content { padding: 12px 10px; }

  /* Page header menor */
  .ph { margin-bottom: 14px; }
  .ph h1 { font-size: 1.2rem; }

  /* KPI: 2 por linha */
  .krow { gap: 8px; }
  .kpi { flex: 1 1 calc(50% - 4px); min-width: calc(50% - 4px); padding: 14px 12px; }
  .kv { font-size: 1.55rem; }
  .kl { font-size: .65rem; }

  /* Cards: scroll horizontal para tabelas geradas pelo JS E pelo HTML estático */
  .card { overflow-x: auto; }
  .table-wrap { overflow-x: unset; border-radius: 0 0 12px 12px; }

  /* Tabelas principais: largura mínima para não quebrar colunas */
  .content .card table { min-width: 520px; }
  /* Tabelas dentro de modal/drawer: não forçar min-width */
  .modal table, .drawer table { min-width: unset; }

  /* Form grids: 1 coluna */
  .fg, .fg3 { grid-template-columns: 1fr; }

  /* Toolbar */
  .tb { flex-direction: column; align-items: stretch; gap: 8px; }
  .sw { max-width: 100%; }

  /* Filtros pill wrap */
  .fps { gap: 4px; }

  /* Modal: quase fullscreen — sobe da base */
  .ov { padding: 6px; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 94vh;
    border-radius: 14px 14px 0 0;
  }
  .modal-sm { max-width: 100%; }

  /* Financeiro — barra de botões: empilha em 2 colunas */
  .chd { flex-direction: column; align-items: stretch; gap: 8px; }
  .chd > div { width: 100%; }
  .chd > div:last-child {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  /* Botão Gerar ocupa linha inteira (destaque) */
  .chd > div:last-child #btn-fin-gerar { grid-column: 1 / -1; }

  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; }
  .tcrumb { font-size: .75rem; }
  .tbadge { display: none; } /* esconde no mobile para economizar espaço */
}

/* ── Mobile pequeno: 400px ── */
@media (max-width: 400px) {
  .kpi { flex: 1 1 100%; min-width: 100%; }
  .kv { font-size: 1.35rem; }
  .btn { font-size: .76rem; padding: 6px 8px; }
}
