:root {
  --navy: #1f3a5f;
  --navy-2: #2c5282;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #dfe4eb;
  --text: #1c2430;
  --muted: #6b7685;
  --ok: #1e7a4c;
  --ok-bg: #e5f4ec;
  --warn: #9a6200;
  --warn-bg: #fdf3e0;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg); min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 12px; }

/* ---- Barre du haut ---- */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo {
  width: 28px; height: 28px; border-radius: 7px; background: #fff; color: var(--navy);
  display: grid; place-items: center; font-weight: 800;
}
#nav { display: flex; gap: 4px; flex: 1; }
#nav button {
  background: transparent; border: 0; color: #c9d6e6; padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit;
}
#nav button.active, #nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.who { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.who .link { color: #c9d6e6; }

/* ---- Mise en page ---- */
main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 14px; }
.subtitle { color: var(--muted); margin: 0 0 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }

/* ---- Formulaires ---- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: #fff;
}
input:focus, select:focus { outline: 2px solid #9db8dc; border-color: var(--navy-2); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 180px; margin-bottom: 0; }
button {
  font: inherit; cursor: pointer; border-radius: 7px; padding: 9px 16px; border: 1px solid var(--line);
  background: #fff; color: var(--text);
}
button:hover { border-color: #b9c3d0; }
button.primary { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--navy-2); }
button.primary:disabled { background: #9aa8b8; border-color: #9aa8b8; cursor: not-allowed; }
button.danger { color: var(--bad); }
button.sm { padding: 4px 10px; font-size: 12px; }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 7px; margin-bottom: 14px; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 7px; margin-bottom: 14px; }
.success { background: var(--ok-bg); color: var(--ok); padding: 10px 12px; border-radius: 7px; margin-bottom: 14px; }

/* ---- Connexion ---- */
.auth-wrap { min-height: 80vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { color: var(--navy); justify-content: center; margin-bottom: 18px; font-size: 20px; }
.auth-card .logo { background: var(--navy); color: #fff; }
.auth-card button.primary { width: 100%; margin-top: 6px; }

/* ---- Dépôt de fichiers ---- */
.dropzone {
  border: 2px dashed #b9c6d6; border-radius: var(--radius); padding: 38px 20px; text-align: center;
  background: #fafbfd; cursor: pointer; transition: background .15s, border-color .15s;
}
.dropzone:hover, .dropzone.over { background: #eef3fa; border-color: var(--navy-2); }
.dropzone strong { display: block; font-size: 15px; margin-bottom: 4px; }
.file-list { list-style: none; margin: 16px 0 0; padding: 0; }
.file-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; margin-bottom: 6px; background: #fff;
}
.file-list .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 12px; flex-wrap: wrap; }

/* ---- Tableaux ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 4px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* ---- Interrupteur ---- */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #c7ced8; border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ---- Fenêtre modale & notification ---- */
.modal { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: grid; place-items: center; z-index: 10; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 22px; width: min(440px, 92vw); }
.modal-box h3 { margin: 0 0 12px; }
.modal-actions { text-align: right; margin-top: 16px; }
.secret {
  font: 600 18px/1.4 ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--line);
  padding: 10px 12px; border-radius: 7px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 10px 18px; border-radius: 8px; z-index: 20; max-width: 90vw;
}
.toast.bad { background: var(--bad); }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  main { padding: 20px 14px; }
}
#result:not(:empty) { margin-top: 16px; }
.row > .field.field-sm { flex: 0 0 120px; min-width: 120px; }
.period { margin-bottom: 18px; }
.period .period-info { flex: 2; align-self: center; margin: 0; padding-top: 18px; }
.checklist { border: 1px solid var(--line); border-left: 4px solid #f0b837; border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; background: #fffdf6; }
.checklist-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; padding: 5px 0; cursor: pointer; margin: 0; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--navy); }
