/* ============================================
   MMI Previs.io — Design System
   ============================================ */

/* --- Variables --- */
:root {
  --primary: #3C3C78;
  --primary-dark: #2c2c5a;
  --primary-light: #6a6aa0;
  --primary-50: #f0f0f6;
  --primary-100: #dddde8;

  --accent: #ffaa00;
  --accent-dark: #cc8800;
  --accent-light: #ffd166;
  --accent-50: #fff8e6;
  --accent-100: #ffeecc;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-dark: #065f46;

  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-dark: #92400e;

  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-dark: #991b1b;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
}

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--primary-100);
  color: var(--primary-dark);
}

a { color: var(--primary); text-decoration: none; transition: color 150ms ease; }
a:hover { color: var(--primary-dark); }

/* --- Navbar --- */
.navbar {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gray-900);
  text-decoration: none;
}

.navbar-brand:hover { color: var(--gray-900); }

.navbar-logo {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.95rem;
}

.navbar-center {
  display: flex;
  align-items: center;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  transition: all 150ms ease;
}

.nav-link:hover {
  background: var(--gray-100);
  color: var(--gray-800);
}

.nav-link.active {
  background: var(--primary-50);
  color: var(--primary);
}

.nav-link svg {
  flex-shrink: 0;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-700);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.navbar-logout {
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-400);
  transition: all 150ms ease;
}

.navbar-logout:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.navbar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--gray-600);
  border-radius: var(--radius-xs);
  transition: background 150ms ease;
}

.navbar-toggle:hover {
  background: var(--gray-100);
}

/* --- Container --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--gray-500);
  font-size: 0.9rem;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

/* --- Year Selector --- */
.page-header-selectors {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.year-selector select {
  padding: 6px 28px 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font);
  font-weight: 500;
  background: white;
  color: var(--gray-700);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.year-selector select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60, 60, 120, 0.1);
}

/* --- Cards --- */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  transition: box-shadow 200ms ease;
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -0.01em;
}

.card-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--gray-100);
  color: var(--gray-500);
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* --- Tables --- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: var(--gray-50);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending {
  background: var(--warning-bg);
  color: var(--warning-dark);
}

.badge-approved {
  background: var(--success-bg);
  color: var(--success-dark);
}

.badge-rejected {
  background: var(--danger-bg);
  color: var(--danger-dark);
}

.badge-info {
  background: var(--primary-50);
  color: var(--primary);
  font-size: 0.7rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: none;
  transition: all 150ms ease;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  color: white;
  box-shadow: 0 4px 14px rgba(60, 60, 120, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

.btn-outline {
  background: white;
  border: 1.5px solid var(--gray-200);
  color: var(--gray-600);
  padding: 8px 16px;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-50);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-xs);
}

/* --- Forms --- */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: white;
  transition: all 150ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60, 60, 120, 0.12);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-400);
}

/* --- Search Bar --- */
.search-bar {
  position: relative;
  min-width: 280px;
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.search-bar input {
  padding-left: 38px;
  border-color: var(--gray-200);
  background: var(--gray-50);
}

.search-bar input:focus {
  background: white;
  border-color: var(--primary);
}

/* --- Alerts / Flash Messages --- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 300ms ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-dark);
  border: 1px solid #a7f3d0;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger-dark);
  border: 1px solid #fecaca;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: box-shadow 200ms ease;
}

.stat-card:hover {
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 500;
}

.stat-pending .stat-value { color: var(--warning); }
.stat-approved .stat-value { color: var(--success); }
.stat-rejected .stat-value { color: var(--danger); }

/* --- MCCC Category Cards --- */
.mccc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.mccc-category {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 200ms ease;
}

.mccc-category:hover {
  box-shadow: var(--shadow);
}

.mccc-category-header {
  padding: 12px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-blue { background: var(--primary); }
.dot-green { background: var(--success); }
.dot-orange { background: var(--warning); }
.dot-red { background: var(--danger); }

.mccc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
  transition: background 150ms ease;
}

.mccc-item:last-child { border-bottom: none; }

.mccc-item:hover { background: var(--gray-50); }

.mccc-item-label {
  color: var(--gray-600);
  font-weight: 500;
}

.mccc-item-values {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mccc-pct {
  font-weight: 700;
  color: var(--gray-800);
  min-width: 50px;
  text-align: right;
}

.mccc-nb {
  color: var(--gray-400);
  font-size: 0.8rem;
  font-weight: 500;
}

/* --- Coefficient Chips --- */
.coef-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.coef-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  min-width: 110px;
  transition: all 200ms ease;
}

.coef-chip:hover {
  box-shadow: 0 4px 12px rgba(60, 60, 120, 0.15);
  transform: translateY(-2px);
}

.coef-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 4px;
}

.coef-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: -0.02em;
}

/* --- Module Header --- */
.module-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.module-code {
  padding: 8px 14px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.module-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.module-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--gray-500);
}

.module-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.module-meta svg {
  color: var(--gray-400);
}

/* --- Back Link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-400);
  margin-bottom: 16px;
  transition: all 150ms ease;
}

.back-link:hover {
  color: var(--primary);
  gap: 8px;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  color: var(--gray-300);
}

.empty-state p {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-500);
}

.empty-state .empty-sub {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 4px;
  font-weight: 400;
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3C3C78 0%, #2c2c5a 100%);
  padding: 24px;
}

.login-page::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(255,255,255,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.05) 0%, transparent 50%);
  pointer-events: none;
}

.login-card {
  position: relative;
  background: white;
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header .login-logo {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 1.4rem;
  margin: 0 auto 16px;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.login-header p {
  color: var(--gray-500);
  font-size: 0.9rem;
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #3C3C78 0%, #2c2c5a 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 8px;
  transition: all 200ms ease;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(60, 60, 120, 0.4);
}

.btn-login:active {
  transform: translateY(0);
  box-shadow: none;
}

.register-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.register-step2 {
  margin-top: 4px;
}

.register-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--gray-500);
}

.register-footer a {
  font-weight: 600;
}

/* --- Misc --- */
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--gray-500); }
.nowrap { white-space: nowrap; }
.module-id-link { font-weight: 700; color: var(--primary); }
.module-id-link:hover { color: var(--primary-dark); }

.coef-dots {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.no-results {
  display: none;
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
  font-size: 0.9rem;
  font-weight: 500;
}

.no-results.visible {
  display: block;
}

/* --- Volume Horaire Etudiants --- */
.vol-hours-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.vol-hours-item {
  text-align: center;
  padding: 16px 12px;
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}

.vol-hours-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 4px;
}

.vol-hours-count {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
  letter-spacing: -0.03em;
}

.vol-hours-label {
  font-size: 0.7rem;
  color: var(--gray-400);
  font-weight: 500;
  margin-bottom: 6px;
}

.vol-hours-eqtd {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  padding: 2px 8px;
  background: var(--primary-50);
  border-radius: 9999px;
  display: inline-block;
}

/* --- Hour Request Form --- */
.hour-request-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.hour-request-field {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
}

.hour-request-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.hour-request-current {
  font-size: 0.7rem;
  color: var(--gray-400);
  margin-bottom: 8px;
}

.hour-request-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hour-request-input-wrap input[type="number"] {
  width: 70px;
  padding: 6px 8px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-xs);
  background: white;
}

.hour-request-input-wrap input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60, 60, 120, 0.12);
}

.hour-request-unit {
  font-size: 0.75rem;
  color: var(--gray-400);
  font-weight: 500;
}

/* --- Redistribution Table --- */
.redistrib-input {
  width: 64px;
  padding: 5px 6px;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-xs);
  background: white;
  color: var(--gray-800);
  transition: all 150ms ease;
}

.redistrib-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60, 60, 120, 0.12);
}

.redistrib-table td {
  vertical-align: middle;
}

/* --- Conformite Maquette --- */
.conformity-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.conformity-item {
  text-align: center;
  padding: 16px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  background: var(--gray-50);
}

.conformity-ok {
  border-color: #a7f3d0;
  background: var(--success-bg);
}

.conformity-ko {
  border-color: #fecaca;
  background: var(--danger-bg);
}

.conformity-warn {
  border-color: #fde68a;
  background: var(--warning-bg);
}

.conformity-neutral {
  border-color: var(--primary-100);
  background: var(--primary-50);
}

.conformity-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.conformity-ok .conformity-label { color: var(--success-dark); }
.conformity-ko .conformity-label { color: var(--danger-dark); }
.conformity-warn .conformity-label { color: var(--warning-dark); }
.conformity-neutral .conformity-label { color: var(--primary); }

.conformity-values {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--gray-900);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.conformity-sep {
  font-size: 1rem;
  font-weight: 500;
  color: var(--gray-400);
  margin: 0 2px;
}

.conformity-expected {
  color: var(--gray-500);
}

.conformity-sub {
  font-size: 0.65rem;
  color: var(--gray-400);
  font-weight: 500;
  margin-top: 4px;
}

.conformity-text-ko {
  color: var(--danger) !important;
  font-weight: 700;
}

/* --- Status Dots --- */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-ok {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.status-warn {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.status-empty {
  background: var(--gray-300);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.15);
}

/* --- Career Grid --- */
.career-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.career-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 200ms ease;
}

.career-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: inherit;
}

.career-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.career-card-content {
  flex: 1;
  min-width: 0;
}

.career-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}

.career-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--gray-400);
  font-weight: 500;
}

.career-card-arrow {
  color: var(--gray-300);
  flex-shrink: 0;
  transition: all 200ms ease;
}

.career-card:hover .career-card-arrow {
  color: var(--primary);
  transform: translateX(3px);
}

/* --- Intervenants --- */
.intervenant-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.intervenant-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-600);
  white-space: nowrap;
}

.leader-tag {
  background: var(--primary-50);
  color: var(--primary);
}

.badge-leader {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--accent);
  color: var(--primary-dark);
  vertical-align: middle;
  margin-left: 4px;
}

/* --- Share Bar --- */
.share-bar {
  position: relative;
  display: inline-block;
  background: var(--gray-100);
  border-radius: 3px;
  height: 6px;
  min-width: 60px;
  overflow: visible;
}
.share-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.2s ease;
}
.share-bar-label {
  position: absolute;
  right: -32px;
  top: -4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
}

.share-pct {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary-50);
  color: var(--primary);
  white-space: nowrap;
}

/* --- Module Management (admin) --- */
.manage-select {
  padding: 4px 8px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font);
  background: white;
  color: var(--gray-700);
  max-width: 180px;
}
.manage-select-sm {
  max-width: 110px;
}
.manage-input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font);
  text-align: right;
  color: var(--gray-700);
}
.manage-input:focus, .manage-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(60, 60, 120, 0.1);
}
.manage-add-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.manage-add-grid .manage-select,
.manage-add-grid .manage-input {
  width: 100%;
  max-width: none;
}
.manage-add-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.btn-danger {
  background: var(--red);
  color: white;
  border: none;
}
.btn-danger:hover {
  background: #b91c1c;
}

/* --- Ordonnancement modules --- */
.order-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.order-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.order-label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.order-add-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Volume Horaire --- */
.text-right { text-align: right; }

.volume-career-card {
  margin-bottom: 8px;
  border-left: 4px solid var(--primary);
}

.volume-career-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.volume-groups {
  display: flex;
  gap: 6px;
}

.volume-group-chip {
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary-50);
  color: var(--primary);
}

.vol-cell {
  font-variant-numeric: tabular-nums;
  color: var(--gray-600);
}

.vol-total {
  font-weight: 700;
  color: var(--gray-800);
}

.volume-subtotal td {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--gray-600);
  border-top: 2px solid var(--gray-200);
  border-bottom: none;
}

.volume-total-card {
  margin-bottom: 32px;
  border: 1.5px solid var(--primary-100);
  background: var(--primary-50);
}

.volume-total-card:hover {
  box-shadow: 0 4px 12px rgba(60, 60, 120, 0.12);
}

.volume-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.volume-total-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.volume-total-values {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.volume-total-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}

.volume-total-num {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.volume-total-sub {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
}

.volume-total-highlight .volume-total-num {
  color: var(--primary);
  font-size: 1.5rem;
}

.volume-total-highlight .volume-total-sub {
  color: var(--primary);
}

/* --- Service Bounds --- */
.service-card-under {
  border-color: #fde68a;
  background: var(--warning-bg);
}

.service-card-under .volume-total-label {
  color: var(--warning-dark);
}

.service-card-under .volume-total-highlight .volume-total-num,
.service-card-under .volume-total-highlight .volume-total-sub {
  color: var(--warning);
}

.service-card-over {
  border-color: #fecaca;
  background: var(--danger-bg);
}

.service-card-over .volume-total-label {
  color: var(--danger-dark);
}

.service-card-over .volume-total-highlight .volume-total-num,
.service-card-over .volume-total-highlight .volume-total-sub {
  color: var(--danger);
}

.service-gauge {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.service-gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.service-gauge-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  font-variant-numeric: tabular-nums;
}

.service-gauge-track {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.service-gauge-min {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--gray-500);
  z-index: 2;
  border-radius: 1px;
}

.service-gauge-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--success), #34d399);
  transition: width 600ms ease;
}

.service-gauge-fill.under {
  background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.service-gauge-fill.over {
  background: linear-gradient(90deg, var(--warning), var(--danger));
}

.service-gauge-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
}

.volume-gauge {
  padding: 12px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
}

.volume-gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.volume-gauge-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  font-variant-numeric: tabular-nums;
}

.volume-gauge-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.volume-gauge-pct.over {
  color: var(--danger);
}

.volume-gauge-track {
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
}

.volume-gauge-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--success), #34d399);
  transition: width 600ms ease;
}

.volume-gauge-fill.over {
  background: linear-gradient(90deg, var(--warning), var(--danger));
}

.volume-gauge-warn {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--danger);
}

/* --- Settings Page --- */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  transition: all 200ms ease;
}

.settings-item:hover {
  border-color: var(--primary-light);
}

.settings-inactive {
  opacity: 0.5;
}

.settings-inactive:hover {
  opacity: 0.8;
}

.settings-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.settings-item-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--gray-900);
}

.settings-item-fields {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-field label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
}

/* --- Toggle Switch --- */
.toggle-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch {
  width: 36px;
  height: 20px;
  background: var(--gray-300);
  border-radius: 10px;
  position: relative;
  transition: background 200ms ease;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 200ms ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-label input:checked + .toggle-switch {
  background: var(--success);
}

.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(16px);
}

/* --- Expandable Detail Rows --- */
.expandable-row {
  cursor: pointer;
  transition: background 150ms ease;
}

.expandable-row:hover {
  background: var(--primary-50) !important;
}

.expandable-row.row-expanded {
  background: var(--primary-50);
  border-bottom-color: var(--primary-100);
}

.expandable-row td:first-child .module-id-link::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--gray-400);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  margin-right: 8px;
  transition: transform 200ms ease;
  vertical-align: middle;
}

.expandable-row.row-expanded td:first-child .module-id-link::before {
  transform: rotate(90deg);
  border-left-color: var(--primary);
}

.detail-row {
  display: none;
}

.detail-row.detail-open {
  display: table-row;
}

.detail-row td {
  padding: 0 !important;
  border-bottom: 2px solid var(--primary-100);
}

.detail-panel {
  padding: 20px;
  background: var(--gray-50);
  border-top: 1px solid var(--primary-100);
  animation: detailSlideDown 200ms ease;
}

@keyframes detailSlideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-columns {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  margin-bottom: 16px;
}

.detail-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.detail-chips {
  display: flex;
  gap: 8px;
}

.detail-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  background: white;
  border: 1px solid var(--gray-200);
  min-width: 60px;
}

.detail-chip-ok {
  border-color: #a7f3d0;
  background: var(--success-bg);
}

.detail-chip-ko {
  border-color: #fecaca;
  background: var(--danger-bg);
}

.detail-chip-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
}

.detail-chip-ok .detail-chip-label { color: var(--success-dark); }
.detail-chip-ko .detail-chip-label { color: var(--danger-dark); }

.detail-chip-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-800);
  font-variant-numeric: tabular-nums;
}

.detail-intervenants {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-intervenant {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  background: white;
  border: 1px solid var(--gray-200);
  font-size: 0.8rem;
}

.detail-intervenant-me {
  border-color: var(--primary-light);
  background: var(--primary-50);
}

.detail-intervenant-name {
  font-weight: 600;
  color: var(--gray-700);
}

.detail-intervenant-me .detail-intervenant-name {
  color: var(--primary);
}

.detail-intervenant-hours {
  color: var(--gray-500);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.detail-adjust-form {
  cursor: default;
}

.detail-adjust-fields {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-adjust-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-adjust-field label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
}

.detail-adjust-desc {
  flex: 1;
  min-width: 150px;
}

.detail-adjust-desc input {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.85rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-xs);
  font-family: var(--font);
}

.detail-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .navbar {
    padding: 0 16px;
  }

  .navbar-center,
  .navbar-right {
    display: none;
  }

  .navbar-toggle {
    display: flex;
  }

  .navbar.mobile-open {
    flex-wrap: wrap;
    height: auto;
    padding-bottom: 12px;
  }

  .navbar.mobile-open .navbar-center {
    display: flex;
    width: 100%;
    order: 3;
    padding-top: 8px;
  }

  .navbar.mobile-open .navbar-nav {
    flex-direction: column;
    width: 100%;
  }

  .navbar.mobile-open .nav-link {
    justify-content: flex-start;
    padding: 10px 14px;
  }

  .navbar.mobile-open .navbar-right {
    display: flex;
    width: 100%;
    order: 4;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
    margin-top: 8px;
  }

  .container {
    padding: 20px 16px 40px;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

  .page-header-row {
    flex-direction: column;
  }

  .search-bar {
    min-width: 100%;
  }

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

  .module-header {
    flex-direction: column;
    gap: 10px;
  }

  .module-code {
    align-self: flex-start;
  }

  .coef-grid {
    justify-content: center;
  }

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

  .vol-hours-grid,
  .hour-request-grid {
    grid-template-columns: 1fr;
  }

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

  td, th {
    padding: 10px 12px;
  }

  .volume-career-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .volume-total-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .settings-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-item-fields {
    width: 100%;
    justify-content: flex-start;
  }

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

  .detail-adjust-fields {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-adjust-fields .btn {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .stat-card {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
  }

  .stat-value {
    font-size: 1.5rem;
    margin-bottom: 0;
    order: 2;
  }

  .stat-label {
    order: 1;
  }

  .login-card {
    padding: 28px 24px;
  }

  .coef-chip {
    min-width: 90px;
    padding: 10px 16px;
  }

  .coef-value {
    font-size: 1.25rem;
  }
}
