:root {
  --ink: #242037;
  --muted: #716c85;
  --line: #e2deef;
  --surface: #ffffff;
  --background: #f6f4fb;
  --primary: #5846ad;
  --primary-dark: #40328b;
  --primary-soft: #eeeafd;
  --success: #217a50;
  --success-soft: #e9f7ef;
  --warning: #9a6500;
  --warning-soft: #fff6dc;
  --danger: #ae3547;
  --danger-soft: #ffedf0;
  --shadow: 0 18px 50px rgba(51, 40, 94, .09);
  --radius: 22px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--background); color: var(--ink); line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 3vw, 2.8rem); line-height: 1.08; }
h2 { font-size: clamp(1.2rem, 2vw, 1.55rem); }
h3 { font-size: 1.03rem; }
code { background: #f0edf8; padding: .1rem .35rem; border-radius: 6px; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 13px; padding: 12px 14px; background: #fff; color: var(--ink); }
textarea { resize: vertical; min-height: 180px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(88, 70, 173, .14); border-color: var(--primary); }
.offline-banner { position: fixed; inset: 0 0 auto 0; z-index: 100; padding: 10px 20px; background: var(--warning-soft); color: #684400; text-align: center; font-weight: 700; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at top left, #e4ddff, transparent 40%), radial-gradient(circle at bottom right, #dff7f5, transparent 38%), var(--background); }
.auth-card { width: min(600px, 100%); padding: clamp(28px, 5vw, 54px); border-radius: 34px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.8); }
.brand-mark { display: grid; place-items: center; width: 82px; height: 82px; border-radius: 25px; background: linear-gradient(145deg, #4c38a0, #7964d7); color: #fff; font-size: 2rem; font-weight: 900; box-shadow: 0 14px 30px rgba(88,70,173,.25); }
.brand-mark.small { width: 52px; height: 52px; border-radius: 17px; font-size: 1.35rem; }
.eyebrow { margin-bottom: 8px; color: var(--primary); font-size: .78rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.auth-copy { color: var(--muted); font-size: 1.08rem; }
.auth-panel { margin-top: 30px; }
.form-stack { display: grid; gap: 18px; }
.form-message { min-height: 24px; margin: 14px 0 0; color: var(--success); }
.form-message.error { color: var(--danger); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid var(--line); border-radius: 13px; padding: 9px 16px; background: #fff; color: var(--ink); font-weight: 800; text-decoration: none; }
.btn:hover { border-color: #b9b0d9; transform: translateY(-1px); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: inherit; }
.btn.link { background: transparent; color: var(--primary); border-color: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; border-radius: 10px; font-size: .86rem; }
.btn.wide { width: 100%; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 18px; background: #27213f; color: #fff; z-index: 20; }
.sidebar-brand { display: flex; align-items: center; gap: 14px; padding: 4px 7px 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-brand strong { display: block; font-size: 1.25rem; }
.sidebar-brand span { color: #cbc4e8; font-size: .88rem; }
.desktop-nav { display: grid; gap: 6px; margin-top: 24px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; border-radius: 14px; padding: 12px 14px; background: transparent; color: #ddd8ef; font-weight: 760; text-align: left; }
.nav-item span { width: 22px; text-align: center; }
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-footer { margin-top: auto; display: grid; gap: 16px; }
.sync-status { display: flex; align-items: center; gap: 9px; color: #ccc6e7; font-size: .85rem; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #a8a2bd; }
.sync-dot.online { background: #66d394; box-shadow: 0 0 0 5px rgba(102,211,148,.12); }
.sync-dot.syncing { background: #f2c24f; animation: pulse 1s infinite; }
.sync-dot.error { background: #f07383; }
@keyframes pulse { 50% { opacity: .35; } }
.main { min-width: 0; padding: 28px clamp(20px, 4vw, 56px) 90px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.topbar h1 { margin: 0; }
.top-actions, .card-actions, .library-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.view { display: grid; gap: 22px; }
.hero { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding: clamp(24px, 4vw, 38px); border-radius: 28px; color: #fff; background: linear-gradient(135deg, #33296f, #6652bd); box-shadow: var(--shadow); }
.hero p { color: #e8e4fa; max-width: 820px; }
.hero-number { min-width: 150px; text-align: center; font-size: clamp(2.8rem, 6vw, 5rem); font-weight: 900; line-height: .9; }
.hero-number small { display: block; margin-top: 10px; font-size: .82rem; font-weight: 700; line-height: 1.2; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.metric-card, .panel, .session-card, .compact-card, .task-card, .library-course { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 9px 30px rgba(55,45,92,.045); }
.metric-card { padding: 20px; }
.metric-card span { display: block; color: var(--muted); font-size: .78rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.metric-card strong { display: block; margin: 6px 0 3px; font-size: 2rem; line-height: 1.1; }
.metric-card small { color: var(--muted); }
.panel { padding: 22px; min-width: 0; }
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(320px,.8fr); gap: 20px; align-items: start; }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; align-items: start; }
.today-layout { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(300px,.7fr); gap: 20px; align-items: start; }
.today-side { display: grid; gap: 20px; }
.session-card { padding: 22px; }
.panel > .session-card { box-shadow: none; }
.session-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.session-head h3 { margin-bottom: 9px; font-size: 1.3rem; }
.meta { display: flex; flex-wrap: wrap; gap: 7px; }
.chip, .badge { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; padding: 5px 9px; background: #f1eef8; color: #534a72; font-size: .75rem; font-weight: 850; }
.badge-terminee { color: var(--success); background: var(--success-soft); }
.badge-en_cours { color: var(--warning); background: var(--warning-soft); }
.badge-a_reprendre { color: var(--danger); background: var(--danger-soft); }
.badge-stabilisee { color: var(--success); background: var(--success-soft); }
.subject-management { background: #eeeafd; color: #5140a5; }
.subject-rh { background: #fce9f2; color: #9a3f70; }
.subject-economie { background: #e4f5f1; color: #147360; }
.subject-droit { background: #fff0dc; color: #9b5a00; }
.shift-note { margin: 14px 0 0; padding: 9px 12px; border-radius: 10px; background: var(--warning-soft); color: #725000; font-size: .86rem; }
.session-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin: 20px 0; }
.session-grid > div { padding: 14px; border-radius: 13px; background: #faf9fd; border: 1px solid #ece8f4; }
.session-grid p, .session-grid ul { margin: 5px 0 0; color: #5f5970; }
.session-grid ul { padding-left: 20px; }
.session-grid .span-2 { grid-column: 1 / -1; }
.note-block { background: #fff9e9 !important; }
.progress-row { display: grid; grid-template-columns: 150px 1fr 52px; gap: 12px; align-items: center; margin: 18px 0; }
.progress-row div:first-child strong, .progress-row div:first-child span { display: block; }
.progress-row div:first-child span { color: var(--muted); font-size: .78rem; }
.progress-track { height: 10px; border-radius: 999px; overflow: hidden; background: #ebe8f2; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5140a5, #7c68d5); }
.notice { padding: 14px 17px; border-radius: 14px; border: 1px solid var(--line); background: #fff; }
.notice.info { background: #eff6ff; border-color: #d3e7ff; color: #315b86; }
.notice.ok { background: var(--success-soft); border-color: #c5ecd7; color: #286746; }
.notice.warn { background: var(--warning-soft); border-color: #f0dfa7; color: #735000; }
.notice.danger { background: var(--danger-soft); border-color: #f5cbd2; color: #872a3a; }
.compact-card { padding: 14px; margin-top: 11px; box-shadow: none; }
.compact-card p { color: var(--muted); margin-bottom: 8px; }
.task-line { display: flex; grid-template-columns: auto 1fr; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.task-line input { width: auto; margin-top: 5px; }
.task-line small { display: block; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 16px; border-radius: 16px; background: #fff; border: 1px solid var(--line); }
.toolbar label { min-width: 180px; }
.toolbar .grow { flex: 1; }
.sticky-toolbar { position: sticky; top: 10px; z-index: 10; box-shadow: var(--shadow); }
.month-list { display: grid; gap: 16px; }
.month { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.month > summary, .library-course > summary { cursor: pointer; list-style: none; padding: 18px 20px; font-size: 1.15rem; font-weight: 850; }
.month > summary { display: flex; justify-content: space-between; text-transform: capitalize; }
.month > summary span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.day-list { border-top: 1px solid var(--line); }
.day-row { display: grid; grid-template-columns: 185px minmax(0,1fr); border-bottom: 1px solid var(--line); }
.day-row:last-child { border-bottom: 0; }
.day-date { padding: 16px 18px; background: #faf9fd; }
.day-date strong, .day-date span { display: block; text-transform: capitalize; }
.day-date span { color: var(--muted); font-size: .82rem; }
.day-content { padding: 15px 18px; }
.day-row.rest .day-content { background: #fbfbfb; }
.rest-label { color: var(--muted); font-style: italic; }
.planning-session { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.planning-session h3 { margin: 7px 0 4px; }
.planning-session p { color: var(--muted); margin-bottom: 4px; }
.muted { color: var(--muted); }
.task-card, .resource-row { display: flex; justify-content: space-between; gap: 15px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--line); }
.task-card { padding: 16px; margin-top: 12px; box-shadow: none; }
.task-card h3 { margin: 4px 0; }
.task-card p { color: var(--muted); margin: 0; }
.switch-label { display: flex; align-items: center; gap: 8px; }
.switch-label input { width: auto; }
.journal-grid { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(320px,.8fr); gap: 20px; align-items: start; }
.timeline-entry { display: grid; grid-template-columns: 145px minmax(0,1fr); gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.timeline-entry time { color: var(--muted); font-size: .82rem; }
.timeline-entry p { margin: 4px 0; color: var(--muted); }
.error-card { padding: 14px 0; border-bottom: 1px solid var(--line); }
.error-card h3 { margin: 8px 0; }
.import-layout { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(320px,.8fr); gap: 20px; align-items: start; }
.preview-list { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; }
.preview-list dt { color: var(--muted); font-weight: 800; }
.preview-list dd { margin: 0; }
.library-list { display: grid; gap: 16px; }
.library-course { overflow: hidden; }
.library-course > summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.library-course > summary h2 { margin: 3px 0; }
.library-course > summary p { color: var(--muted); margin: 0; font-size: .85rem; }
.course-outline { display: grid; gap: 18px; padding: 0 22px 22px; border-top: 1px solid var(--line); }
.course-outline section { padding-top: 18px; }
.course-outline details { border-top: 1px solid #ece9f4; padding: 8px 0; }
.course-outline details summary { cursor: pointer; font-weight: 750; }
.course-outline details summary span { float: right; color: var(--muted); font-size: .8rem; }
.course-outline ul { color: var(--muted); }
.resource-row { padding: 12px 0; }
.resource-row p { color: var(--muted); margin: 2px 0; }
.empty-state { padding: 22px; border: 1px dashed #cfc8e0; border-radius: 16px; color: var(--muted); text-align: center; }
.toast { position: fixed; z-index: 200; right: 22px; bottom: 22px; max-width: min(430px, calc(100vw - 44px)); padding: 13px 17px; border-radius: 13px; background: #27213f; color: #fff; box-shadow: var(--shadow); font-weight: 700; }
.toast.error { background: var(--danger); }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 230px minmax(0,1fr); }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid, .today-layout, .journal-grid, .import-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main { padding: 18px 14px 92px; }
  .topbar { align-items: flex-start; }
  .top-actions { justify-content: flex-end; }
  .top-actions .btn { padding: 8px 10px; font-size: .82rem; }
  .metrics-grid, .two-columns { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero-number { text-align: left; }
  .session-grid { grid-template-columns: 1fr; }
  .session-grid .span-2 { grid-column: auto; }
  .session-head, .panel-title, .library-course > summary, .planning-session { flex-direction: column; }
  .progress-row { grid-template-columns: 105px 1fr 42px; }
  .day-row { grid-template-columns: 1fr; }
  .day-date { padding: 10px 14px; display: flex; justify-content: space-between; gap: 10px; }
  .timeline-entry { grid-template-columns: 1fr; gap: 4px; }
  .sticky-toolbar { position: static; }
  .mobile-nav { position: fixed; z-index: 50; inset: auto 0 0 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 7px max(7px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); background: rgba(39,33,63,.97); backdrop-filter: blur(14px); }
  .mobile-nav .nav-item { display: grid; justify-items: center; gap: 1px; padding: 6px 3px; border-radius: 10px; font-size: 1.1rem; }
  .mobile-nav .nav-item small { font-size: .62rem; }
  .auth-screen { padding: 16px; }
  .auth-card { padding: 26px 20px; border-radius: 24px; }
}
