/* =========================================================
   Painel de Serviços & Folha de Pagamento — estilos base
   Design: neutro, objetivo, um único acento (teal)
   ========================================================= */

:root{
  --bg:       #F6F7F9;  /* fundo geral, cinza muito claro */
  --surface:  #FFFFFF;  /* cartões e tabelas */
  --border:   #E7E9EE;  /* linhas finas / divisórias */
  --ink:      #16191D;  /* texto principal */
  --muted:    #6E7480;  /* texto secundário / rótulos */
  --accent:   #2E6F6A;  /* único destaque (teal escuro): ações, links, foco */
  --accent-soft:#E6F0EF;
  --ok:       #2F855A;  /* concluído / pago */
  --ok-soft:  #E6F4EC;
  --warn:     #B7791F;  /* agendado / pendente */
  --warn-soft:#FBF0DD;
  --danger:   #C0392B;  /* cancelado / atraso */
  --danger-soft:#FBEAE7;
  --radius:   10px;
  --shadow:   0 1px 2px rgba(16,25,40,.06), 0 1px 1px rgba(16,25,40,.04);
  --rail-width: 220px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .25em; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 .75em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Números: tabular-nums para alinhar valores */
.num, .kpi-value, td.num, th.num, .table td.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Foco de teclado visível */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* =========================================================
   Layout: rail lateral + conteúdo
   ========================================================= */

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

.rail {
  width: var(--rail-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail-brand {
  font-weight: 600;
  font-size: 15px;
  padding: 8px 12px 16px;
  color: var(--ink);
}

.rail-brand small {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
}

.nav-link:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-icon {
  width: 18px;
  text-align: center;
  color: var(--muted);
}

.nav-link.active .nav-icon { color: var(--accent); }

.rail-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.rail-footer form { margin-top: 6px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 24px 28px 60px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

/* Botão de menu mobile (oculto em telas largas) */
.menu-toggle { display: none; }

/* =========================================================
   Cartões / KPIs
   ========================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--ink);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
}

.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}

.chart-wrap {
  position: relative;
  height: 280px;
}

/* =========================================================
   Filtros de período
   ========================================================= */

.period-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.period-filter a, .period-filter button {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.period-filter a.active, .period-filter button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.period-filter a:hover { text-decoration: none; border-color: var(--accent); }

.period-filter form {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* =========================================================
   Tabelas
   ========================================================= */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--accent-soft); }

.table td.num, .table th.num { text-align: right; }

.table tfoot td {
  font-weight: 600;
  background: var(--bg);
  border-top: 2px solid var(--border);
  border-bottom: none;
}

/* =========================================================
   Pílulas de status
   ========================================================= */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-ok      { background: var(--ok-soft);    color: var(--ok); }
.pill-warn    { background: var(--warn-soft);  color: var(--warn); }
.pill-danger  { background: var(--danger-soft);color: var(--danger); }

/* =========================================================
   Formulários
   ========================================================= */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 70px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-direction: row;
}

.checkbox-row input { width: auto; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* =========================================================
   Botões
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover { border-color: var(--accent); text-decoration: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: #275f5b; border-color: #275f5b; }

.btn-danger {
  color: var(--danger);
  border-color: var(--danger-soft);
}

.btn-danger:hover { border-color: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: 13px; }

/* =========================================================
   Mensagens flash
   ========================================================= */

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #cdeada; }
.alert-error   { background: var(--danger-soft); color: var(--danger); border-color: #f4d3cd; }

.field-error {
  color: var(--danger);
  font-size: 12px;
}

/* =========================================================
   Estados vazios
   ========================================================= */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state h3 { color: var(--ink); margin-bottom: 6px; }

/* =========================================================
   Login
   ========================================================= */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 { margin-bottom: 4px; }
.login-card p.subtitle { color: var(--muted); margin-bottom: 20px; }

/* =========================================================
   Utilitários
   ========================================================= */

.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* =========================================================
   Responsivo: rail vira topo no celular
   ========================================================= */

/* =========================================================
   Impressão
   ========================================================= */

.only-print { display: none; }

@media print {
  .rail, .menu-toggle, .no-print, .alert { display: none !important; }
  .only-print { display: inline-flex; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .card, .table-wrap { box-shadow: none; border: none; }
}

@media (max-width: 820px) {
  .app-shell { flex-direction: column; }

  .rail {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 2px;
  }

  .rail-brand { padding: 4px 10px; flex: 1 1 100%; }

  .rail-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 4px;
    padding-top: 8px;
  }

  .rail-nav.open { display: flex; }

  .menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .rail-footer {
    margin-top: 0;
    border-top: none;
    width: 100%;
    display: none;
  }

  .rail-footer.open { display: block; }

  .main { padding: 16px; }

  .kpi-value { font-size: 24px; }
}
