:root {
  --bg: #eef3f1;
  --panel: #ffffff;
  --line: #d9e2df;
  --text: #16211f;
  --muted: #64716d;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --danger: #b91c1c;
  --shadow: 0 16px 40px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button, input, select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

label {
  display: grid;
  gap: 6px;
  color: #34423f;
  font-weight: 700;
}

h1, h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 { font-size: 26px; }
h2 { font-size: 18px; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, .12), transparent 45%),
    linear-gradient(300deg, rgba(180, 83, 9, .12), transparent 45%),
    var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  font-size: 14px;
}

.primary {
  color: #fff;
  background: var(--primary);
  font-weight: 800;
}

.primary:hover { background: var(--primary-dark); }

.secondary {
  color: var(--primary-dark);
  background: #e3efec;
  font-weight: 800;
}

.status {
  min-height: 22px;
  margin: 0;
}

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 18px;
  background: #f8fbfa;
  border-right: 1px solid var(--line);
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-row span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

.nav {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  color: #33423f;
  background: transparent;
  font-weight: 800;
}

.nav.active, .nav:hover {
  background: #dcebe8;
  color: var(--primary-dark);
}

.nav.is-locked {
  color: #7c5a19;
  background: #fff8e6;
}

.nav.is-locked::after {
  content: "Verrouille";
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #9a6700;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  gap: 16px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.trial-banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid #f0c36a;
  border-radius: 8px;
  background: #fff8e6;
  color: #6f4e00;
  font-weight: 800;
}

.locked-module {
  border-color: #f0c36a;
  background: #fff8e6;
  color: #6f4e00;
  font-weight: 800;
}

.toolbar {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.page { display: none; }
.page.active { display: grid; gap: 16px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.metrics article, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.metrics article {
  padding: 16px;
  display: grid;
  gap: 8px;
}

.metrics span {
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.metrics strong {
  font-size: 30px;
}

.panel {
  padding: 16px;
  overflow: auto;
}

.panel-title-row {
  display: flex;
  gap: 14px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-title-row p {
  margin: 6px 0 0;
}

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

.tab {
  padding: 9px 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: #33423f;
  font-weight: 800;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid #edf2f0;
  text-align: left;
  vertical-align: top;
}

th {
  color: #465551;
  background: #f7faf9;
  font-size: 13px;
}

.table-empty {
  padding: 18px;
  color: var(--muted);
  background: #f8fbfa;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.item, .split-list article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.item strong, .split-list strong {
  display: block;
  margin-bottom: 4px;
}

.split-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff7ed;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.badge.neutral {
  background: #e8f3f1;
  color: var(--primary-dark);
}

.badge.danger {
  background: #fee2e2;
  color: var(--danger);
}

.notes-entry-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(180px, 1.2fr) minmax(150px, .8fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.notes-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-end;
}

.notes-entry-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.notes-entry-table .table-empty {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.notes-table {
  min-width: 860px;
}

.notes-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.notes-table td:first-child {
  min-width: 240px;
}

.student-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.score-input {
  width: 96px;
  min-height: 36px;
  text-align: center;
  font-weight: 800;
}

.computed-average {
  color: var(--primary-dark);
  font-weight: 900;
}

@media (max-width: 920px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }

  nav {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .topbar, .toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .notes-entry-controls {
    grid-template-columns: 1fr 1fr;
  }

  .notes-actions {
    justify-content: start;
  }
}

@media (max-width: 520px) {
  .workspace, .sidebar, .login-view {
    padding: 12px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .panel-title-row,
  .notes-entry-controls,
  .notes-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
