@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --sidebar-w: 260px;
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #8b5cf6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #1e40af;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.1);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── LAYOUT ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 100;
}
.sidebar-brand {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .logo {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .logo-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-brand .logo-text { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.3; }
.sidebar-brand .logo-sub { color: var(--sidebar-text); font-size: 11px; font-weight: 400; }

.sidebar-divider { height: 1px; background: rgba(255,255,255,.07); margin: 4px 20px; }
.sidebar-section { padding: 8px 12px 4px; }
.sidebar-section-label {
  color: #475569; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px;
  padding: 0 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  transition: all .18s; margin-bottom: 2px; border: none; background: none; width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px;
  padding: 1px 6px;
}

/* ── MAIN ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow); flex-shrink: 0;
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.competencia-select {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px;
  font-family: inherit; font-size: 13px; background: var(--bg); color: var(--text);
  cursor: pointer;
}
.btn {
  padding: 8px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; transition: all .18s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

.content { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* ── CARDS ── */
.cards-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.yellow { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }
.stat-icon.purple { background: #ede9fe; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.1; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; text-align: left; font-size: 11px;
  font-weight: 700; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .5px; border-bottom: 1px solid var(--border);
  background: var(--bg); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 16px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .18s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--card); transition: border .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(59,130,246,.12);
}
.form-group textarea { resize: vertical; min-height: 70px; }
.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox-item input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.toggle-group { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle-btn {
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text-muted); transition: all .15s;
}
.toggle-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── CHECKLIST ── */
.checklist-category { margin-bottom: 20px; }
.checklist-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 700;
  cursor: pointer; user-select: none;
}
.checklist-header .cat-count { margin-left: auto; font-size: 12px; opacity: .8; }
.checklist-body { border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.checklist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item-name { flex: 1; font-size: 13px; }
.checklist-item-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.status-select {
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px;
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.status-select.recebido { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.status-select.incompleto { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.status-select.nao_enviado { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.status-select.divergente { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.status-select.aguardando { background: #f1f5f9; color: #475569; border-color: var(--border); }

/* ── AUDIT ── */
.audit-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; margin-bottom: 10px;
}
.audit-item-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.risk-indicator { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.risk-low { background: var(--success); }
.risk-med { background: var(--warning); }
.risk-high { background: var(--danger); }
.audit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── EDUCATION ── */
.edu-section { margin-bottom: 20px; }
.edu-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--primary); color: #fff; border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
}
.edu-header h3 { font-size: 14px; font-weight: 700; }
.edu-body {
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  padding: 18px; display: none;
}
.edu-body.open { display: block; }
.edu-rule {
  display: flex; gap: 10px; margin-bottom: 12px; padding: 12px;
  border-radius: var(--radius-sm); background: var(--bg);
  border-left: 3px solid var(--primary-light); font-size: 13px;
}
.edu-rule strong { display: block; margin-bottom: 2px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(2px);
}
.modal {
  background: var(--card); border-radius: 14px; width: 700px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── SEARCH ── */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
}
.search-bar input {
  border: none; background: none; font-family: inherit; font-size: 13px;
  color: var(--text); flex: 1; outline: none;
}

/* ── PARECER ── */
.parecer-box {
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; white-space: pre-wrap;
  font-size: 13px; line-height: 1.7; font-family: 'Inter', sans-serif;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── PROGRESS ── */
.progress-bar { background: var(--border); border-radius: 10px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--primary-light), var(--accent)); transition: width .4s; }

/* ── ONBOARDING ── */
.doc-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.doc-item:last-child { border-bottom: none; }
.doc-code { font-size: 10px; font-weight: 700; color: var(--text-muted); white-space: nowrap; background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.doc-name { flex: 1; font-size: 13px; }
.doc-obs { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-style: italic; }

/* ── UTILS ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) { .cards-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand .logo-text, .nav-item span, .sidebar-section-label { display: none; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ── MONTH PICKER ── */
.month-picker { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; min-width: 240px; }
.month-picker-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-picker-year { font-weight: 700; font-size: 14px; }
.month-picker-nav { border: none; background: none; cursor: pointer; font-size: 16px; color: var(--text-muted); padding: 2px 8px; border-radius: 4px; }
.month-picker-nav:hover { background: var(--bg); color: var(--text); }
.month-picker-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; }
.month-btn {
  padding: 7px 4px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 500; color: var(--text-muted); transition: all .15s;
  text-align: center;
}
.month-btn:hover { border-color: var(--primary-light); color: var(--primary); background: #eff6ff; }
.month-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.month-btn.has-data { border-color: var(--success); }
.month-btn.has-data.full { background: #d1fae5; border-color: var(--success); color: #065f46; }
.month-btn.has-data.partial { background: #fef3c7; border-color: var(--warning); color: #92400e; }

/* ── KANBAN HISTORY ── */
.kanban-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 14px; margin-top: 6px; }
.kanban-card {
  background: var(--card); border-radius: var(--radius); border: 2px solid var(--border);
  padding: 14px 16px; cursor: pointer; transition: all .18s;
  position: relative; overflow: hidden;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kanban-card.k-empty { border-color: var(--border); }
.kanban-card.k-partial { border-color: var(--warning); }
.kanban-card.k-full { border-color: var(--success); background: #f0fdf4; }
.kanban-card-month { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.kanban-card-pct { font-size: 22px; font-weight: 800; line-height: 1; }
.kanban-card-sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.kanban-card-bar { height: 4px; border-radius: 4px; background: var(--border); margin-top: 10px; overflow: hidden; }
.kanban-card-fill { height: 100%; border-radius: 4px; }
.kanban-card.k-full .kanban-card-fill { background: var(--success); }
.kanban-card.k-partial .kanban-card-fill { background: var(--warning); }
.kanban-card.k-empty .kanban-card-fill { background: var(--border); }
.kanban-card-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 16px;
}

/* ── CLIENT INFO SUMMARY ── */
.client-summary-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 6px 16px;
  font-size: 12px; margin-top: 8px;
}
.client-summary-item { display: flex; flex-direction: column; gap: 1px; }
.client-summary-label { color: var(--text-muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.client-summary-value { font-weight: 600; color: var(--text); }

