:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #e8e6f0;
  --text2: #9b99a8;
  --text3: #5f5d6e;
  --purple: #7f77dd;
  --purple-light: #afa9ec;
  --purple-bg: rgba(127,119,221,0.12);
  --teal: #1d9e75;
  --teal-light: #5dcaa5;
  --teal-bg: rgba(29,158,117,0.12);
  --coral: #d85a30;
  --coral-bg: rgba(216,90,48,0.12);
  --amber: #ef9f27;
  --amber-bg: rgba(239,159,39,0.12);
  --red: #e24b4a;
  --green: #639922;
  --green-bg: rgba(99,153,34,0.12);
  --radius: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--purple-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
nav {
  background: var(--bg2);
  border-bottom: 0.5px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 52px;
}
.nav-logo {
  font-size: 16px;
  font-weight: 600;
  color: var(--purple-light);
  margin-right: 32px;
  letter-spacing: 0.03em;
}
.nav-link {
  font-size: 14px;
  color: var(--text2);
  padding: 0 14px;
  height: 52px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--purple-light); border-bottom-color: var(--purple); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }
.status-dot.offline { background: var(--red); }

/* Layout */
main { max-width: 900px; margin: 0 auto; padding: 28px 16px; }

/* Cards */
.card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.card + .card { margin-top: 12px; }

/* Stats grid */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--bg3);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label { font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 500; }
.stat-value.purple { color: var(--purple-light); }
.stat-value.teal { color: var(--teal-light); }
.stat-value.amber { color: var(--amber); }

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-header h2 { font-size: 15px; font-weight: 500; color: var(--text2); }

/* Buttons */
.btn {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 0.5px solid var(--border2);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--bg3); }
.btn-primary {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover { background: var(--purple-light); border-color: var(--purple-light); }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 500; }
.btn-teal:hover { background: var(--teal-light); border-color: var(--teal-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--red); border-color: rgba(226,75,74,0.3); }
.btn-danger:hover { background: rgba(226,75,74,0.1); }

/* Badge / pill */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}
.badge-purple { background: var(--purple-bg); color: var(--purple-light); }
.badge-teal { background: var(--teal-bg); color: var(--teal-light); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-coral { background: var(--coral-bg); color: var(--coral); }
.badge-green { background: var(--green-bg); color: #97c459; }

/* Matière row */
.matiere-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--border);
}
.matiere-row:last-child { border-bottom: none; }
.matiere-name { font-size: 15px; font-weight: 500; }
.matiere-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.matiere-actions { display: flex; gap: 6px; }

/* Form */
input[type=text], input[type=file], textarea, select {
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
  font-family: inherit;
}
input[type=text]:focus, textarea:focus { border-color: var(--purple); }
label { font-size: 13px; color: var(--text2); display: block; margin-bottom: 6px; }

/* Modal */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 420px;
  max-width: 92vw;
}
.modal h3 { font-size: 16px; font-weight: 500; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 0.5px solid var(--border2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 200;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { border-color: var(--teal); color: var(--teal-light); }
.toast.error { border-color: var(--red); color: var(--red); }

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text3);
  font-size: 14px;
}

/* Progress bar */
.progress-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--purple);
  border-radius: 2px;
  transition: width 0.3s;
}

/* Loader */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
