* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Identidade visual SINPRF/RS */
  --primary: #282060;        /* azul-marinho institucional */
  --primary-dark: #1B1545;   /* navy mais escuro (hover) */
  --primary-light: #4A4290;  /* navy claro (foco/realces) */
  --secondary: #1F1A4D;      /* navy para cabeçalhos/sidebar */
  --accent: #F8B030;         /* dourado SINPRF */
  --accent-dark: #E09A18;
  --bg: #EEF0F6;             /* fundo claro lavanda */
  --surface: #FFFFFF;
  --text: #1F1A3D;
  --text-muted: #6B6A85;
  --border: #E2E2EC;
  --success: #16A34A;
  --warning: #F59E0B;
  --danger: #E2504B;
  --info: #0EA5E9;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(40,32,96,0.07), 0 4px 12px rgba(40,32,96,0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--primary); text-decoration: none; }

/* === LOGIN === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #282060 0%, #16123A 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  padding: 40px 36px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-card h1 {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 6px;
  text-align: center;
}
.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 13px;
}
.login-card .login-logo {
  display: block;
  width: 96px;
  height: auto;
  margin: 0 auto 14px;
}
.login-card .logo-circle {
  width: 60px; height: 60px;
  background: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 22px;
}

/* === LAYOUT APP === */
.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--secondary);
  color: white;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-header {
  padding: 0 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-header .sidebar-logo {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
}
.sidebar-header h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.sidebar-header p {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  margin-top: 3px;
}
.sidebar-nav { padding: 0 12px; }
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 2px;
  border-radius: 6px;
  color: rgba(255,255,255,0.85);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s;
}
.sidebar-nav button:hover { background: rgba(255,255,255,0.08); }
.sidebar-nav button.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav .icon { width: 18px; text-align: center; font-size: 15px; }
.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  padding: 16px 22px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
}
.sidebar-footer .user-name { font-weight: 600; color: white; }
.sidebar-footer .user-role { color: rgba(255,255,255,0.6); margin: 2px 0 8px; }
.sidebar-footer button {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  padding: 4px 0;
}
.sidebar-footer button:hover { color: white; }

.main {
  padding: 28px 32px;
  overflow-x: hidden;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 14px;
}
.page-header h1 { font-size: 22px; color: var(--secondary); }
.page-header .subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* === FORM === */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(40,32,96,0.15);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.form-checkbox input { width: auto; }

/* === BUTTON === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--primary);
  color: white;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803D; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #B91C1C; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  padding: 6px;
  min-width: 30px;
  min-height: 30px;
  justify-content: center;
}

/* === CARD === */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* === STATS === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--secondary);
  margin-top: 4px;
}
.stat-card .stat-detail {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.info { border-left-color: var(--info); }

/* === TABLE === */
.table-wrapper {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table thead {
  background: var(--secondary);
  color: white;
}
table thead th {
  padding: 11px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

/* Nomes completos sempre em maiusculas e alinhados a esquerda */
table td strong,
.user-name,
.nome-completo,
select option,
select.nome-uppercase {
  text-transform: uppercase;
  text-align: left;
}
table tbody tr:hover { background: #F8FAFC; }
table tbody tr:last-child td { border-bottom: none; }

/* === BADGE === */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-pendente { background: #FEF3C7; color: #92400E; }
.badge-aprovado { background: #D1FAE5; color: #065F46; }
.badge-pago { background: #E3E1F2; color: #282060; }
.badge-rejeitado { background: #FEE2E2; color: #991B1B; }
.badge-integral { background: #DCFCE7; color: #14532D; }
.badge-meia { background: #FEF1CE; color: #8A5A09; }
.badge-banco { background: #E3E1F2; color: #312A6E; }
.badge-renuncia { background: #FCE7F3; color: #831843; }
.badge-master { background: #FBE6BC; color: #8A5A09; }
.badge-usuario { background: #F3F4F6; color: #374151; }

/* === FILTERS === */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: end;
}
.filters .form-group { margin: 0; min-width: 150px; }

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: white;
  border-radius: 10px;
  padding: 24px;
  max-width: 700px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; }
.modal-close { font-size: 22px; color: var(--text-muted); padding: 0 4px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* === ALERT/TOAST === */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--success);
  color: white;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: slideIn 0.25s ease;
}
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === EMPTY/LOADING === */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty .icon { font-size: 36px; margin-bottom: 10px; opacity: 0.3; }
.loading {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
}

/* === CHARTS === */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.chart-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 14px; margin-bottom: 12px; color: var(--secondary); }

/* === HELPERS === */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-bold { font-weight: 700; }
.mt-2 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.flex { display: flex; }
.flex-gap { gap: 10px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }
.actions-cell { white-space: nowrap; }
.actions-cell button { margin-right: 4px; }

/* === HAMBURGER + BACKDROP (mobile drawer) === */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--secondary);
  color: white;
  padding: 10px 14px;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.topbar h1 { font-size: 15px; font-weight: 700; letter-spacing: 0.4px; }
.hamburger {
  background: transparent;
  border: 0;
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
}
.hamburger:active { background: rgba(255,255,255,0.1); }
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
}
.backdrop.open { display: block; }

/* === TABLET (até 1024px) === */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 220px 1fr; }
  .sidebar { width: 220px; }
  .main { padding: 22px 20px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .stat-card .stat-value { font-size: 22px; }
  table thead th, table tbody td { padding: 9px 10px; font-size: 12.5px; }
}

/* === MOBILE (até 768px) === */
@media (max-width: 768px) {
  .topbar { display: flex; }
  .app-shell { grid-template-columns: 1fr; }

  /* Sidebar vira drawer off-canvas */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 270px;
    max-width: 80vw;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,0.3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-footer { position: relative; }

  .main {
    padding: 14px 14px 30px;
    min-height: calc(100vh - 60px);
  }

  /* Topo das paginas */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .page-header h1 { font-size: 18px; }
  .page-header .subtitle { font-size: 12.5px; }

  /* Stats viram 2 colunas no celular */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 18px; }
  .stat-card .stat-label { font-size: 10.5px; }
  .stat-card .stat-detail { font-size: 11px; }

  /* Cards e cabecalhos */
  .card { padding: 14px; }
  .card-title { font-size: 14px; }

  /* Filtros empilham no mobile */
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .filters .form-group { min-width: 100%; }
  .filters .btn { width: 100%; justify-content: center; }

  /* Form em coluna unica */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Tabelas: scroll horizontal mais evidente */
  .table-wrapper {
    position: relative;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrapper::after {
    content: "";
    position: sticky;
    right: 0;
    top: 0;
    width: 14px;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(to left, rgba(0,0,0,0.08), transparent);
  }
  table thead th, table tbody td {
    padding: 8px 9px;
    font-size: 12px;
    white-space: nowrap;
  }
  table tbody td { white-space: normal; }
  table thead th:first-child, table tbody td:first-child { white-space: nowrap; }

  /* Botoes maiores para toque */
  .btn { padding: 10px 14px; font-size: 13px; min-height: 38px; }
  .btn-sm { padding: 7px 10px; font-size: 12px; min-height: 32px; }
  .btn-icon, .actions-cell .btn { min-width: 36px; min-height: 36px; }

  /* Charts ocupam toda a largura */
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card { padding: 12px; }
  .chart-card canvas { max-height: 240px; }

  /* Modais mais confortaveis no celular */
  .modal-overlay { padding: 8px; align-items: flex-start; padding-top: 16px; }
  .modal {
    padding: 16px;
    max-height: 96vh;
    border-radius: 8px;
  }
  .modal-header h2 { font-size: 16px; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }

  /* Login: card maior e centralizado */
  .login-card {
    padding: 28px 22px;
  }

  /* Sidebar nav: items maiores para toque */
  .sidebar-nav button { padding: 14px 14px; font-size: 14px; }

  /* Toast no mobile: ocupa toda a largura sem sair da tela */
  .toast {
    top: 10px;
    right: 10px;
    left: 10px;
    text-align: center;
    font-size: 13px;
  }

  /* Acoes em celulas: empilhadas se necessario */
  .actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }
}

/* === MOBILE PEQUENO (até 380px) === */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .main { padding: 12px 10px 24px; }
  .stat-card { padding: 11px; }
  .stat-card .stat-value { font-size: 17px; }
  .topbar h1 { font-size: 13px; }
}
