* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --navy: #1A3C5E;
  --navy-light: #2a5580;
  --gold: #C8922A;
  --gold-light: #e6b34d;
  --bg: #f5f6fa;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --green: #10b981;
  --green-bg: #d1fae5;
  --yellow: #f59e0b;
  --yellow-bg: #fef3c7;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --blue: #3b82f6;
  --blue-bg: #dbeafe;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 8px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ===== LOGIN ===== */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}

.login-box {
  background: var(--white);
  padding: 40px;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo { height: 60px; margin-bottom: 16px; }

.login-box h2 {
  font-size: 18px;
  color: var(--gray-600);
  margin-bottom: 24px;
  font-weight: 500;
}

.login-box input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .2s;
}

.login-box input:focus { border-color: var(--navy); }

.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 20px; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--navy);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background .2s;
}
.btn-primary:hover { background: var(--navy-light); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-small {
  background: transparent;
  color: var(--gray-400);
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.btn-small:hover { color: white; }

.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 4px 8px;
}

.btn-action {
  background: var(--navy);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-action:hover { background: var(--navy-light); }

/* ===== LAYOUT ===== */
#main-screen { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-header { padding: 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-logo { height: 40px; filter: brightness(0) invert(1); }

.nav-list { list-style: none; flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.08); }
.nav-item.active { color: var(--gold); background: rgba(255,255,255,.1); }

.nav-icon { font-size: 8px; width: 16px; text-align: center; }
.nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: 8px 20px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255,255,255,.6);
}

/* ===== CONTENT ===== */
#content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

#topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
#topbar h1 { font-size: 16px; font-weight: 600; flex: 1; }
#menu-toggle { display: none; }
#sidebar-backdrop { display: none; }
@media (max-width: 768px) {
  #sidebar-backdrop.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
  }
}

#page-content { padding: 24px; flex: 1; }

/* ===== DASHBOARD CARDS ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dash-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
}

.dash-card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.dash-card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--navy);
}

.dash-card-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.dash-card.alert { border-left: 4px solid var(--red); }
.dash-card.alert .dash-card-value { color: var(--red); }
.dash-card.ok { border-left: 4px solid var(--green); }
.dash-card.ok .dash-card-value { color: var(--green); }
.dash-card.warn { border-left: 4px solid var(--yellow); }
.dash-card.warn .dash-card-value { color: var(--yellow); }

/* ===== SECTION HEADING ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 15px; font-weight: 600; }

/* ===== DATA GRID (grade meses) ===== */
.grade-container { overflow-x: auto; background: var(--white); border-radius: var(--radius); border: 1px solid var(--gray-200); }

.grade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 900px;
}

.grade-table th {
  background: var(--navy);
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.grade-table th:first-child { min-width: 200px; }

.grade-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

.grade-table tr:hover td { background: var(--gray-50); }

.grade-table .col-nome { font-weight: 500; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* Status cells */
.status-cell {
  width: 36px;
  height: 28px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s;
}
.status-cell:hover { transform: scale(1.15); }

.st-concluido { background: var(--green); color: white; }
.st-em_andamento { background: var(--yellow); color: white; }
.st-pendente { background: var(--gray-200); color: var(--gray-500); }
.st-nao_aplicavel { background: var(--gray-100); color: var(--gray-300); }

/* ===== TABLE (lista simples) ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}

.data-table th {
  background: var(--gray-50);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.data-table tr:hover td { background: var(--gray-50); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: var(--green-bg); color: #065f46; }
.badge-yellow { background: var(--yellow-bg); color: #92400e; }
.badge-red { background: var(--red-bg); color: #991b1b; }
.badge-blue { background: var(--blue-bg); color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* ===== MONTH SELECTOR ===== */
.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}
.month-selector select, .month-selector input {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--white);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 15px; }
#modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Form inside modal */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group input:focus, .form-group select:focus { border-color: var(--navy); }

/* ===== KPI STRIP ===== */
.kpi-strip {
  background: var(--navy);
  border-radius: 12px;
  padding: 24px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-item { text-align: center; color: white; }
.kpi-value { font-size: 32px; font-weight: 700; line-height: 1; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; opacity: .7; margin-top: 6px; }
.kpi-sub { font-size: 11px; opacity: .5; margin-top: 2px; }

/* ===== DASH PANELS ===== */
.dash-panel {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 20px;
}
.dash-panel-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--navy);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--navy);
}
.dash-row { display: grid; gap: 16px; margin-bottom: 16px; }
.dash-row-2 { grid-template-columns: 1fr 1fr; }
.dash-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  /* Sidebar: overlay com backdrop */
  #sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: 4px 0 24px rgba(0,0,0,.3);
  }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0; }
  #menu-toggle { display: block; font-size: 24px; }

  /* Topbar */
  #topbar { padding: 0 12px; gap: 8px; }
  #topbar h1 { font-size: 14px; }
  #topbar-actions { font-size: 11px; }

  /* Page content */
  #page-content { padding: 12px; }

  /* KPI strip */
  .kpi-strip { grid-template-columns: repeat(3, 1fr); padding: 16px 8px; gap: 6px; border-radius: 8px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 10px; }
  .kpi-sub { font-size: 10px; }

  /* Dashboard */
  .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dash-row-2, .dash-row-3 { grid-template-columns: 1fr; }
  .dash-panel { padding: 14px; }
  .dash-panel-title { font-size: 12px; margin-bottom: 12px; }
  .dash-card { padding: 14px; }
  .dash-card-value { font-size: 26px; }

  /* Tabelas: scroll horizontal */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }

  /* Grade de meses */
  .grade-table { min-width: 700px; }
  .grade-table th:first-child { min-width: 140px; }
  .grade-table th, .grade-table td { padding: 6px 8px; font-size: 11px; }
  .status-cell { width: 30px; height: 24px; font-size: 10px; }

  /* Modal: quase full-screen */
  .modal { width: 96%; max-width: none; max-height: 94vh; border-radius: 10px; }
  .modal-header { padding: 12px 16px; }
  .modal-header h3 { font-size: 14px; }
  #modal-body { padding: 14px; }
  .modal-footer { padding: 10px 14px; }

  /* Formulários no modal */
  .form-group { margin-bottom: 10px; }
  .form-group input, .form-group select, .form-group textarea { font-size: 16px; padding: 10px 12px; }

  /* Botões mais touch-friendly */
  .btn-action { padding: 10px 16px; font-size: 13px; }
  .btn-secondary { padding: 8px 12px; font-size: 12px; }

  /* Month selector */
  .month-selector { flex-wrap: wrap; gap: 6px; }
  .month-selector select, .month-selector input { font-size: 13px; padding: 8px 10px; }

  /* Badges */
  .badge { font-size: 10px; padding: 2px 6px; }

  /* Login */
  .login-box { margin: 16px; padding: 28px 20px; }
}

/* ===== MODAL WIDE (vídeos) ===== */
.modal.modal-wide { max-width: 800px; }

/* ===== TUTORIAIS ===== */
.tutoriais-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.tutorial-card {
  background: var(--white);
  border-radius: 8px;
  border: 1px solid var(--gray-200);
  overflow: hidden;
  transition: box-shadow .2s, transform .15s;
}
.tutorial-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateY(-2px); }

.tut-chevron { transform: rotate(0deg); }
.tut-chevron-open { transform: rotate(90deg); }

.tutorial-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--blue-bg);
  color: var(--blue);
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .tutoriais-grid { grid-template-columns: 1fr; }
  /* KPI: 2 por linha + restante embaixo */
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }

  /* Dashboard cards: 1 coluna */
  .dashboard-grid { grid-template-columns: 1fr; }

  /* Tabelas: fonte menor */
  .data-table th, .data-table td { padding: 6px 8px; font-size: 11px; }

  /* Topbar */
  #topbar h1 { font-size: 13px; }

  /* Modal full */
  .modal { width: 100%; max-height: 100vh; border-radius: 0; }
}
