:root {
  --green-bg: #c6efce; --green-fg: #006100;
  --gray-bg: #d9d9d9; --gray-fg: #595959;
  --blue-bg: #bdd7ee; --blue-fg: #1f4e78;
  --red-bg: #ffc7ce; --red-fg: #9c0006;
  --orange-bg: #ffeb9c; --orange-fg: #9c6500;
  --bg: #0f1419;
  --panel: #171d26;
  --panel-2: #1f2733;
  --border: #2a3340;
  --text: #e8edf3;
  --muted: #8b98a8;
  --accent: #4f8cff;
  --accent-2: #39d1b4;
  --radius: 10px;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.3px; }
.topbar .brand span { color: var(--accent-2); }
.topbar .mode-badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: 10px;
  background: var(--orange-bg);
  color: var(--orange-fg);
  font-weight: 600;
}
.mode-badge.synced { background: var(--green-bg); color: var(--green-fg); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 24px; }
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2, .card h3 { margin-top: 0; }

.kpi { text-align: center; }
.kpi .value { font-size: 2rem; font-weight: 700; }
.kpi .label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
.kpi.green .value { color: var(--green-bg); }
.kpi.red .value { color: var(--red-bg); }
.kpi.blue .value { color: var(--blue-bg); }

/* ---------- Botões ---------- */
button, .btn {
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { opacity: 0.9; }
button.danger { color: var(--red-bg); border-color: var(--red-fg); }
button.small { padding: 5px 10px; font-size: 0.8rem; }

input, select, textarea {
  font-family: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
}
label { font-size: 0.82rem; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.tab-btn {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  padding: 10px 16px; color: var(--muted); border-radius: 0;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Timeline ---------- */
.timeline-wrap { overflow-x: auto; padding-bottom: 8px; }
.timeline-month { margin-bottom: 20px; }
.timeline-month h4 { color: var(--muted); font-weight: 600; margin: 0 0 8px 2px; text-transform: capitalize; }
.timeline-grid { display: grid; grid-template-columns: repeat(31, 22px); gap: 3px; }
.tl-day {
  width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 600; cursor: default;
  border: 1px solid rgba(255,255,255,0.06);
}
.tl-day.status-trabalhou { background: var(--green-bg); color: var(--green-fg); }
.tl-day.status-folga { background: var(--gray-bg); color: var(--gray-fg); }
.tl-day.status-feriado { background: var(--gray-bg); color: var(--gray-fg); }
.tl-day.status-ferias { background: var(--blue-bg); color: var(--blue-fg); }
.tl-day.status-atestado { background: var(--red-bg); color: var(--red-fg); }
.tl-day.status-falta_nao_justificada { background: var(--red-bg); color: var(--red-fg); }
.tl-day.status-pendente { background: var(--orange-bg); color: var(--orange-fg); }
.tl-day.empty { background: transparent; border: none; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; font-size: 0.78rem; color: var(--muted); }
.tl-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: var(--panel-2); }
td.status-cell { font-weight: 600; }

.status-pill { padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.status-pill.status-trabalhou { background: var(--green-bg); color: var(--green-fg); }
.status-pill.status-folga, .status-pill.status-feriado { background: var(--gray-bg); color: var(--gray-fg); }
.status-pill.status-ferias { background: var(--blue-bg); color: var(--blue-fg); }
.status-pill.status-atestado, .status-pill.status-falta_nao_justificada { background: var(--red-bg); color: var(--red-fg); }
.status-pill.status-pendente { background: var(--orange-bg); color: var(--orange-fg); }

.table-scroll { max-height: 420px; overflow-y: auto; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--panel-2); border: 1px solid var(--accent-2);
  color: var(--text); padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3); z-index: 100;
}

.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-box { width: 360px; }
.login-box h1 { font-size: 1.3rem; }
.muted { color: var(--muted); font-size: 0.85rem; }

.upload-drop {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 28px; text-align: center; color: var(--muted); cursor: pointer;
}
.upload-drop:hover { border-color: var(--accent); color: var(--text); }
