:root {
  --navy: #1f3a6e;
  --navy-2: #2c4f8f;
  --accent: #0e7c7b;
  --accent-soft: #d8f0ee;
  --red: #c0392b;
  --amber: #b7791f;
  --amber-soft: #fdf3e1;
  --green: #217a4b;
  --green-soft: #e3f4ea;
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #dfe3ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 14px rgba(20, 30, 50, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.hidden { display: none !important; }

/* En-tête */
.top {
  background: var(--navy); color: #fff; border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 20;
}
.top-in { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; letter-spacing: .02em; }
.brand small { display: block; font-weight: 400; opacity: .8; font-size: .78rem; letter-spacing: 0; }
.top .spacer { flex: 1; }
.top .btn-link { color: #fff; opacity: .9; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.narrow { max-width: 460px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; min-width: 200px; }

/* Formulaires */
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 4px 14px 4px 0; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .row.c2 { grid-template-columns: 1fr 1fr; } .row.c3 { grid-template-columns: 1fr 1fr 1fr; } }
.help { color: var(--muted); font-size: .84rem; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 8px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--navy); color: #fff; text-decoration: none; min-height: 42px;
}
.btn:hover { background: var(--navy-2); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.secondary { background: #e8ecf3; color: var(--navy); }
.btn.secondary:hover { background: #dbe2ee; }
.btn.accent { background: var(--accent); }
.btn.danger { background: #fbe9e7; color: var(--red); }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: .86rem; }
.btn-link { background: none; border: 0; padding: 4px; font: inherit; color: var(--navy-2); cursor: pointer; text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.otp { letter-spacing: .5em; font-size: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; }

/* Messages */
.msg { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: .92rem; }
.msg.ok { background: var(--green-soft); color: var(--green); }
.msg.err { background: #fbe9e7; color: var(--red); }
.msg.info { background: #eaf0fa; color: var(--navy); }
.msg.warn { background: var(--amber-soft); color: #7a4f0e; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow);
  max-width: calc(100% - 32px); font-size: .92rem;
}
.toast.err { background: var(--red); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #e8ecf3; color: var(--navy); white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: #7a4f0e; }
.badge.err { background: #fbe9e7; color: var(--red); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #eaf0fa; color: var(--navy); border-radius: 99px; padding: 3px 4px 3px 10px; font-size: .84rem; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 6px; }

/* Tableaux */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }
td.nowrap, th.nowrap { white-space: nowrap; }

/* Onglets */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab[aria-selected=true] { color: var(--navy); border-bottom-color: var(--accent); }

/* Grille de disponibilités */
.weeks-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.weeks-nav button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font: inherit; font-size: .86rem; cursor: pointer; }
.weeks-nav button[aria-pressed=true] { background: var(--navy); color: #fff; border-color: var(--navy); }
.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
table.grid { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 320px; table-layout: fixed; user-select: none; -webkit-user-select: none; }
table.grid th { font-size: .74rem; font-weight: 600; color: var(--muted); padding: 2px; }
table.grid th.time { width: 62px; text-align: right; padding-right: 6px; }
table.grid thead th button, table.grid th.time button {
  border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 4px 2px; width: 100%; line-height: 1.2; border-radius: 6px;
}
table.grid thead th button:hover, table.grid th.time button:hover { background: #eef1f6; }
table.grid td { padding: 0; }
.cell {
  display: block; width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; padding: 0;
  touch-action: manipulation; font-size: .72rem; color: var(--muted);
}
.cell[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.cell[aria-pressed=true]::after { content: "✓"; }
.cell:disabled { background: repeating-linear-gradient(45deg, #f1f2f5, #f1f2f5 4px, #e7e9ee 4px, #e7e9ee 8px); cursor: not-allowed; border-color: transparent; }
.grid.readonly .cell { cursor: default; }
.cell.heat { font-weight: 700; color: var(--ink); }
.grid tr.lunch td, .grid tr.lunch th { padding-top: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; border: 1px solid var(--line); background: #fff; }
.legend .l-on::before { background: var(--accent); border-color: var(--accent); }
.legend .l-off::before { background: repeating-linear-gradient(45deg, #f1f2f5, #f1f2f5 3px, #e7e9ee 3px, #e7e9ee 6px); }

.seq-card.saved { border-left: 4px solid var(--green); }
.seq-card.pending { border-left: 4px solid var(--amber); }
.seq-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }

/* Planning */
.day-block { margin-bottom: 14px; }
.day-block h3 { font-size: .95rem; color: var(--navy); margin: 0 0 6px; }
.day-block h3::first-letter { text-transform: uppercase; }
.week-one { margin: 6px 0; }
.assign { display: grid; grid-template-columns: 100px 1fr; gap: 4px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: #fff; }
.assign .when { font-weight: 700; font-variant-numeric: tabular-nums; }
.assign .what strong { display: block; }
.assign .tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
@media (min-width: 720px) { .assign { grid-template-columns: 120px 1fr auto; align-items: center; } .assign .tools { grid-column: auto; justify-content: flex-end; } }
.assign.locked { border-color: var(--accent); background: #f6fbfb; }
.week-title { font-size: 1.02rem; margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--line); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat b { display: block; font-size: 1.5rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat span { font-size: .82rem; color: var(--muted); }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(640px, calc(100% - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: inherit; }
dialog::backdrop { background: rgba(15, 25, 45, .45); }
dialog .dlg-in { padding: 20px; max-height: 85vh; overflow-y: auto; }
.checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.checklist label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 4px 0; }

.log { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; white-space: pre-wrap; background: #f7f8fb; padding: 10px; border-radius: 8px; max-height: 340px; overflow: auto; }

@media print {
  .top, .tabs, .actions, .tools, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; padding: 0; }
}
