:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e6f0;
  --text: #1e2433;
  --muted: #6b7280;
  --primary: #0f6e5c;
  --primary-dark: #0b5445;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --focus-color: #1d4ed8;
  --font-scale: 1;
}

:root[data-contrast="high"] {
  --bg: #000000;
  --surface: #111111;
  --border: #ffffff;
  --text: #ffffff;
  --muted: #f5f5f5;
  --primary: #ffd60a;
  --primary-dark: #ffd60a;
  --focus-color: #ffd60a;
}

* { box-sizing: border-box; }

html { font-size: calc(100% * var(--font-scale)); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
:root[data-reduce-motion="true"] * {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary-dark); }
img { max-width: 100%; }

:focus-visible { outline: 3px solid var(--focus-color); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--primary); color: #fff; padding: 10px 18px; z-index: 1000; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #14203a;
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.sidebar .brand span { color: #7dd3bf; }
.brand-logo-only { max-height: 40px; max-width: 160px; width: auto; height: auto; object-fit: contain; }
.sidebar .employee-info { font-size: 12px; color: #b7c0d6; margin-bottom: 20px; }
.sidebar nav { flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: #cbd2e1; text-decoration: none; padding: 10px 12px; border-radius: 8px; margin-bottom: 4px; font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar .badge-count {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; padding: 1px 7px;
}
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.sidebar-footer form { flex: 1; }
.sidebar-footer button {
  width: 100%; background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px; padding: 8px; cursor: pointer; font-size: 13px;
}
.sidebar-footer button:hover { background: rgba(255,255,255,0.18); }

.main { flex: 1; padding: 26px 30px; max-width: 1200px; }

.page-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { margin: 0; font-size: 21px; }
.page-header p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.btn {
  background: var(--primary); color: #fff; border: none; padding: 10px 16px; border-radius: 8px;
  cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f1f3f9; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-card .label { font-size: 13px; color: var(--muted); }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .layout { flex-direction: column; } .sidebar { width: 100%; } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filters input, .filters select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.status-aberto { background: #e5e7eb; color: #4b5563; }
.badge.status-andamento { background: #fef3c7; color: var(--warning); }
.badge.status-concluido { background: #dcfce7; color: var(--success); }
.badge.status-cancelado { background: #fee2e2; color: var(--danger); }
.badge.priority-baixa { background: #e5e7eb; color: #4b5563; }
.badge.priority-media { background: #dbeafe; color: #1d4ed8; }
.badge.priority-alta { background: #fef3c7; color: var(--warning); }
.badge.priority-urgente { background: #fee2e2; color: var(--danger); }
.badge.role-rh { background: #ede9fe; color: #6d28d9; }
.badge.role-marketing { background: #fce7f3; color: #be185d; }
.badge.role-qualidade { background: #dbeafe; color: #1d4ed8; }
.badge.role-colaborador { background: #e5e7eb; color: #4b5563; }
.badge.active-true { background: #dcfce7; color: var(--success); }
.badge.status-pendente { background: #fef3c7; color: var(--warning); }
.badge.status-pendente_gestor { background: #fef3c7; color: var(--warning); }
.badge.status-pendente_rh { background: #fef3c7; color: var(--warning); }
.badge.status-aprovado { background: #dcfce7; color: var(--success); }
.badge.status-rejeitado { background: #fee2e2; color: var(--danger); }
.badge.status-aberta { background: #dcfce7; color: var(--success); }
.badge.status-encerrada { background: #e5e7eb; color: #4b5563; }
.badge.status-matriculado { background: #dbeafe; color: #1d4ed8; }
.badge.status-em_andamento { background: #fef3c7; color: var(--warning); }
.badge.status-reprovado { background: #fee2e2; color: var(--danger); }
.badge.status-rascunho { background: #e5e7eb; color: #4b5563; }
.badge.status-publicado { background: #dcfce7; color: var(--success); }
.badge.status-encerrado { background: #e5e7eb; color: #4b5563; }

.course-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.course-card .course-meta { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.course-card .course-meta span { margin-right: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-label { width: 160px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: var(--bg); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--primary); height: 100%; }
.bar-value { width: 60px; text-align: right; flex-shrink: 0; }

.question-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

.progress-bar { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar .fill { background: var(--primary); height: 100%; }
.checklist-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.checklist-item:last-child { border-bottom: none; }
.badge.active-false { background: #fee2e2; color: var(--danger); }

.pinned-tag { background: var(--warning); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 8px; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,18,30,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-overlay.hidden { display: none; }
.hidden { display: none !important; }

.calendar-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar-table th { text-align: center; padding: 8px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.calendar-cell { border: 1px solid var(--border); vertical-align: top; height: 100px; padding: 6px; width: 14.28%; }
.calendar-cell.out-month { background: var(--bg); opacity: 0.5; }
.calendar-day-number { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.calendar-shift-chip {
  background: var(--primary); color: #fff; border-radius: 6px; padding: 3px 6px;
  font-size: 11px; line-height: 1.3; margin-bottom: 3px;
}
.calendar-shift-chip.clickable { cursor: pointer; }
@media (max-width: 700px) {
  .calendar-table, .calendar-table thead, .calendar-table tbody, .calendar-table tr, .calendar-table td { display: block; width: 100%; }
  .calendar-table thead { display: none; }
  .calendar-cell { height: auto; min-height: 40px; margin-bottom: 4px; }
}
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-top: 0; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit;
}
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-hint { font-size: 0.85rem; color: var(--muted); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.actions-cell { display: flex; gap: 6px; }

.announcement-card { border-left: 4px solid var(--border); }
.announcement-card.pinned { border-left-color: var(--warning); }
.announcement-meta { color: var(--muted); font-size: 12px; margin-top: 6px; }

.employee-card { display: flex; gap: 14px; align-items: center; }
.employee-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--surface); flex-shrink: 0; }
.employee-avatar-placeholder {
  width: 56px; height: 56px; border-radius: 50%; background: var(--surface); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex-shrink: 0;
}

.document-icon { width: 40px; height: 40px; border-radius: 8px; background: var(--surface); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--login-gradient-start, #0b5445), var(--login-gradient-end, #14203a));
}
.login-card { background: transparent; padding: 34px; width: 100%; max-width: 380px; color: #fff; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; color: #fff; }
.login-card p.subtitle { color: rgba(255,255,255,0.85); margin-top: 0; margin-bottom: 20px; font-size: 14px; }
.login-card .form-row label { color: #fff; }
.login-card .form-row input {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
}
.login-card .form-row input::placeholder { color: rgba(255,255,255,0.65); }
.login-card a { color: #fff; }
.alert-error { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-success { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

.status-msg { font-size: 0.85rem; margin-top: 8px; display: block; }
.status-msg.ok { color: #166534; }
.status-msg.error { color: #991b1b; }

.avatar-upload { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* Menu de acessibilidade lateral */
.a11y-toggle {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 200;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px 0 0 8px;
  padding: 14px 8px;
  cursor: pointer;
  font-size: 13px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 0.5px;
}
.a11y-toggle:hover { background: var(--primary-dark); }

.a11y-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 300px;
  max-width: 85vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0,0,0,0.15);
  z-index: 210;
  padding: 22px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.a11y-panel.open { transform: translateX(0); }
.a11y-panel h2 { font-size: 16px; margin-top: 0; }
.a11y-panel .a11y-group { margin-bottom: 22px; }
.a11y-panel .a11y-group h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.a11y-panel .a11y-row { display: flex; gap: 8px; flex-wrap: wrap; }
.a11y-panel button.a11y-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}
.a11y-panel button.a11y-btn:hover { background: var(--border); }
.a11y-panel button.a11y-btn[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.a11y-panel .a11y-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); line-height: 1;
}
.a11y-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 205;
  display: none;
}
.a11y-backdrop.open { display: block; }

/* Menu mobile */
.nav-toggle {
  display: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; padding: 14px 16px; }
  .sidebar-top { display: flex; align-items: center; justify-content: space-between; }
  .nav-toggle { display: inline-flex; }
  .sidebar nav { display: none; margin-top: 14px; }
  .sidebar nav.open { display: block; }
  .main { padding: 18px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .card { overflow-x: auto; }
  table { min-width: 560px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .a11y-toggle { top: auto; bottom: 16px; right: 0; transform: none; writing-mode: horizontal-tb; padding: 10px 14px; border-radius: 8px 0 0 8px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { padding: 18px; }
}
