/* ================== SGF — Tema Pastel ================== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e8eaf2;
  --text: #3d4356;
  --text-soft: #8a90a5;
  --primary: #7c9ff2;        /* azul pastel */
  --primary-soft: #e3ebfd;
  --primary-dark: #5a80e0;
  --green: #7fc8a0;          /* verde suave */
  --green-soft: #e2f4ea;
  --lilac: #b9a7e6;          /* lilás claro */
  --lilac-soft: #efe9fb;
  --beige: #e9ddc8;          /* bege claro */
  --beige-soft: #f8f3e9;
  --rose: #eba7ab;
  --rose-soft: #fbe9ea;
  --amber: #e8c377;
  --amber-soft: #faf1dd;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(61, 67, 86, .06), 0 6px 20px rgba(61, 67, 86, .05);
  --sidebar-width: 210px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: 'Poppins', 'Inter', sans-serif; font-weight: 600; color: #333a4e; margin: 0 0 .4em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.ico { vertical-align: -3px; flex-shrink: 0; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: margin-left .25s ease;
  z-index: 50;
  container-type: inline-size;
  container-name: sidebar;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px 16px;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}
.brand-logo {
  flex: 0 0 44px;
  width: 44px; min-width: 44px; height: 44px; min-height: 44px;
  aspect-ratio: 1 / 1;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--lilac) 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 15px;
}
.brand-copy {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.brand-name { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 17px; letter-spacing: .3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--text-soft); margin-top: -3px; white-space: normal; overflow: hidden; }

@container sidebar (max-width: 260px) {
  .brand-sub { white-space: nowrap; text-overflow: ellipsis; }
}
@container sidebar (max-width: 220px) {
  .brand-sub { display: none; }
}
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-soft); padding: 18px 24px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9.5px 13px; border-radius: 10px;
  color: var(--text); font-weight: 500; font-size: 13.8px;
  transition: background .15s;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav a .ico { color: var(--text-soft); }
.nav a.active .ico { color: var(--primary-dark); }
.sidebar-footer { margin-top: auto; padding: 14px 12px 18px; border-top: 1px solid var(--border); }
.sidebar-backdrop { display: none; }
.sidebar-resizer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 8px;
  cursor: col-resize; z-index: 55; touch-action: none;
  background: transparent;
}
.sidebar-resizer::after {
  content: ''; position: absolute; top: 10%; left: 3px; height: 80%; width: 2px;
  border-radius: 1px; background: transparent; transition: background .2s;
}
.sidebar-resizer:hover::after { background: var(--primary-soft); }
body.sidebar-resizing .sidebar-resizer::after { background: var(--primary); }
body.sidebar-resizing { cursor: col-resize !important; user-select: none; }
.nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-name, .brand-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 62px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 40;
}
.burger { display: none; background: none; border: none; cursor: pointer; color: var(--text); padding: 6px; }
.topbar-search { flex: 1; max-width: 420px; position: relative; min-width: 0; }
.topbar-search .ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; display: block;
  color: var(--text-soft); pointer-events: none;
}
.topbar-search input[type="text"] {
  display: block; width: 100%; min-width: 0; box-sizing: border-box;
  padding: 9px 12px 9px 48px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); font: inherit; color: var(--text);
}
.topbar-search input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  position: relative; background: none; border: none; cursor: pointer;
  color: var(--text-soft); padding: 9px; border-radius: 10px; display: flex;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.badge-dot {
  position: absolute; top: 5px; right: 5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--rose); color: #fff; border-radius: 8px;
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.profile-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; cursor: pointer; border: none; background: none; font: inherit; }
.profile-chip:hover { background: var(--bg); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--lilac-soft); color: var(--lilac);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.profile-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.profile-role { font-size: 11px; color: var(--text-soft); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 60;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--text); font-size: 13.5px;
}
.dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.notif-menu { min-width: 320px; max-height: 400px; overflow-y: auto; }
.notif-item { display: block; padding: 10px 12px; border-radius: 8px; }
.notif-item:hover { background: var(--bg); text-decoration: none; }
.notif-item.unread { background: var(--primary-soft); }
.notif-item .t { font-weight: 600; font-size: 13px; color: var(--text); }
.notif-item .m { font-size: 12.5px; color: var(--text-soft); }
.notif-item .d { font-size: 11px; color: var(--text-soft); margin-top: 2px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 20px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title h2 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; gap: 14px; align-items: center;
}
.stat-icon { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; }
.stat-icon.c-blue  { background: var(--primary-soft); color: var(--primary-dark); }
.stat-icon.c-green { background: var(--green-soft); color: #4da87c; }
.stat-icon.c-lilac { background: var(--lilac-soft); color: #8f77cc; }
.stat-icon.c-amber { background: var(--amber-soft); color: #c99b3f; }
.stat-icon.c-rose  { background: var(--rose-soft); color: #d47b81; }
.stat-value { font-family: 'Poppins', sans-serif; font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--text-soft); }

/* ---------- Grid helpers ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 13.8px; }
.tbl th {
  text-align: left; padding: 11px 14px;
  background: #fafbfe; color: var(--text-soft);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fbfcff; }
.tbl .actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; min-width: 120px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3.5px 11px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-success { background: var(--green-soft); color: #3f9068; }
.badge-warn    { background: var(--amber-soft); color: #b3872e; }
.badge-danger  { background: var(--rose-soft); color: #c9666d; }
.badge-info    { background: var(--primary-soft); color: var(--primary-dark); }
.badge-muted   { background: #eef0f5; color: var(--text-soft); }
.badge-lilac   { background: var(--lilac-soft); color: #8f77cc; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9.5px 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: filter .15s, background .15s; text-decoration: none !important;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(.94); }
.btn-danger { background: var(--rose); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: none; color: var(--text-soft); padding: 7px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-soft); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel], select, textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 88px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* Upload */
.file-drop {
  border: 1.5px dashed var(--border); border-radius: 12px;
  padding: 18px; text-align: center; color: var(--text-soft);
  background: #fbfcfe; cursor: pointer; transition: border-color .15s;
  font-size: 13px;
}
.file-drop:hover { border-color: var(--primary); }
.file-drop input { display: none; }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 150px; flex: 0 1 auto; }
.filters .field input, .filters .field select { padding: 8px 11px; }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  padding: 9px 16px; font-weight: 600; font-size: 13.5px; color: var(--text-soft);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* ---------- Alertas / flash ---------- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; }
.alert-success { background: var(--green-soft); color: #3f9068; }
.alert-danger  { background: var(--rose-soft); color: #c9666d; }
.alert-info    { background: var(--primary-soft); color: var(--primary-dark); }
.alert-warn    { background: var(--amber-soft); color: #b3872e; }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(40, 45, 60, .4);
  z-index: 100; align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
  width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; padding: 24px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 18px 14px; }
.timeline li::before {
  content: ''; position: absolute; left: -21px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary-soft); border: 3px solid var(--primary);
}
.timeline .tl-title { font-weight: 600; font-size: 13.5px; }
.timeline .tl-meta { font-size: 12px; color: var(--text-soft); }

/* ---------- Calendário ---------- */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: 11px; text-transform: uppercase; color: var(--text-soft); padding: 6px 2px; font-weight: 600; }
.cal td { border: 1px solid var(--border); height: 62px; vertical-align: top; padding: 4px 6px; font-size: 12px; }
.cal td .d { font-weight: 600; color: var(--text-soft); }
.cal td.today { background: var(--primary-soft); }
.cal td.has-ferias { background: var(--green-soft); }
.cal td.has-falta { background: var(--rose-soft); }
.cal .ev { display: block; font-size: 10.5px; margin-top: 2px; padding: 1px 5px; border-radius: 6px; background: var(--surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-day-link { display: block; color: inherit; text-decoration: none; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--primary-soft) 0%, var(--bg) 45%, var(--lilac-soft) 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  width: 100%; max-width: 400px; padding: 38px 34px;
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .brand-logo { width: 54px; height: 54px; font-size: 20px; border-radius: 16px; margin: 0 auto 12px; }

/* ---------- Utilidades ---------- */
.muted { color: var(--text-soft); font-size: 12.5px; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.text-right { text-align: right; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--text-soft); font-size: 13px; }
.empty { text-align: center; color: var(--text-soft); padding: 34px 10px; }
.empty .ico { display: block; margin: 0 auto 10px; opacity: .5; }
.chart-box { position: relative; height: 260px; }

/* ---------- Responsivo ---------- */
@media (max-width: 960px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; margin-left: calc(-1 * var(--sidebar-width) - 10px);
    box-shadow: 0 0 40px rgba(0,0,0,.15);
  }
  body.sidebar-open .sidebar { margin-left: 0; }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(40,45,60,.35); z-index: 45;
  }
  .burger { display: flex; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 14px; }
  .topbar-search { display: none; }
  .profile-info { display: none; }
  .tbl th, .tbl td { padding: 10px 10px; }
  .cal td { height: 46px; padding: 2px 4px; }
  .cal .ev { display: none; }
  .cal td.has-ferias, .cal td.has-falta { border-radius: 4px; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 16px; }
  .filters .field { min-width: 100%; }
  .form-actions .btn { flex: 1; }
  .page-head .btn { width: 100%; }
}
@media (max-width: 430px) {
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head h1 { font-size: 1.25rem; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid, .form-grid .field, .filters { min-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-actions .btn, .page-head .btn { width: 100%; }
  .tbl { font-size: 12.5px; }
  .tbl th, .tbl td { padding: 8px; }
  .actions { gap: 6px; flex-wrap: wrap; }
  .btn-sm { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .modal { margin: 12px; width: auto; }
  .card { padding: 16px; }
}

/* Tabelas sem quebra de linha */
.tbl-nowrap td { white-space: nowrap; }
.tbl-nowrap .actions { flex-wrap: nowrap; }

/* Tabela com ações sticky (ex: funcionarios.php) */
.tbl-actions th,
.tbl-actions td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl-actions td:nth-child(1) { max-width: 280px; }
.tbl-actions td:nth-child(2) { max-width: 160px; }
.tbl-actions td:nth-child(3) { max-width: 160px; }
.tbl-actions th:nth-child(6),
.tbl-actions td:nth-child(6) {
  position: sticky; right: 0; width: 160px; min-width: 160px; max-width: 160px;
  text-align: right; background: var(--surface); z-index: 2;
  box-shadow: -3px 0 6px rgba(0,0,0,.04);
  border-left: 1px solid var(--border);
  padding-right: 18px;
}
.tbl-actions th:nth-child(6) { background: #fafbfe; z-index: 3; }
.tbl-actions tr:hover td:nth-child(6) { background: #fbfcff; }
.tbl-actions .actions { min-width: 0; }
.tbl-actions .actions .btn { padding: 6px 8px; }
