:root {
  --bg: #f4f7fb;
  --ink: #15202b;
  --muted: #667085;
  --panel: #ffffff;
  --line: #d9e2ec;
  --primary: #17324d;
  --accent: #0f8b8d;
  --danger: #b42318;
  --success: #067647;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.sidebar {
  background: var(--primary);
  color: #fff;
  min-height: 100vh;
  padding: 28px 20px;
}

.brand { display: grid; gap: 6px; margin-bottom: 32px; }
.brand span, .muted { color: var(--muted); font-size: 0.9rem; }
.sidebar .brand span { color: #b9c6d3; }

nav { display: grid; gap: 8px; }
nav a {
  color: #fff;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
}
nav a:hover { background: rgba(255,255,255,0.12); }

.content { padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.badge {
  background: #dff6f6;
  color: #075d5f;
  padding: 7px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.page-title { margin-bottom: 22px; }
.page-title h1, .auth-panel h1 { margin: 0 0 6px; font-size: 2rem; }
.page-title p, .auth-panel p { margin: 0; color: var(--muted); }

.auth-panel, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.panel + .panel { margin-top: 18px; }

.auth-panel { max-width: 430px; margin: 8vh auto; }
.narrow { max-width: 560px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stats-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
.stats-grid span { display: block; color: var(--muted); margin-bottom: 8px; }
.stats-grid strong { font-size: 2rem; }
.stats-grid .stat-label { font-size: 1.25rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--primary);
  padding: 5px 10px;
  font-weight: 700;
  font-size: 0.9rem;
}

.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  max-width: 260px;
}

.mini-tags span,
.mini-tags small {
  display: inline-flex;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--primary);
  padding: 3px 7px;
  font-size: 0.78rem;
  font-weight: 700;
}

.mini-tags small {
  color: var(--muted);
  font-weight: 400;
}

.form-stack, .form-grid { display: grid; gap: 12px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.help-text {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

label { display: grid; gap: 6px; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
}
select[multiple] { min-height: 110px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.secondary { background: #e7eef6; color: var(--primary); }
.report-button { background: var(--primary); color: #fff; }
.excel-button { background: #087443; color: #fff; }
.siabot-button { background: #8a4b08; color: #fff; }

.actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.actions-row.compact {
  margin-top: 0;
}

.import-form {
  max-width: 520px;
  margin-top: 14px;
}

.report-panel {
  max-width: 680px;
}

.report-note {
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary);
  padding: 12px;
  font-weight: 700;
}

.report-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.empty-state h2 {
  margin: 0 0 6px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.messages { margin-bottom: 18px; display: grid; gap: 8px; }
.message {
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.message.erro { border-color: #f5b5ad; color: var(--danger); }
.message.sucesso { border-color: #9ce2c2; color: var(--success); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}
th { background: #eef3f8; color: var(--primary); }

.grade-toolbar,
.grade-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.grade-footer {
  margin-top: 16px;
  margin-bottom: 0;
  position: sticky;
  bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.student-name {
  min-width: 220px;
  font-weight: 700;
}

.grades-table input {
  min-width: 74px;
  padding: 8px;
  text-align: center;
}

.grades-table th:not(:first-child),
.grades-table td:not(:first-child) {
  text-align: center;
}

.grade-row.needs-attention {
  background: #fff8f6;
}

.media-value {
  font-size: 1rem;
}

.grade-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.85rem;
  font-weight: 700;
}

.grade-status.ok {
  background: #dcfce7;
  color: var(--success);
}

.grade-status.warning {
  background: #fee4e2;
  color: var(--danger);
}

.editable-table input,
.editable-table select {
  min-width: 130px;
  padding: 8px;
}

.editable-table select[multiple] {
  min-width: 190px;
  min-height: 82px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}

.row-actions form {
  margin: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status.active {
  background: #dcfce7;
  color: var(--success);
}

.status.inactive {
  background: #fee4e2;
  color: var(--danger);
}

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .content { padding: 20px; }
  .grid-2, .stats-grid, .dashboard-grid, .form-grid, .link-grid { grid-template-columns: 1fr; }
  .report-actions { grid-template-columns: 1fr; }
  .grade-toolbar, .grade-footer { align-items: stretch; flex-direction: column; }
}
