:root {
  --navy: #463f63; --navy-2: #5b5480; --accent: #3b8577; --accent-2: #e7f3f0;
  --bg: #f3f4f8; --card: #fff; --line: #e2e6ec; --text: #1f2933; --muted: #6b7684;
  --ok: #1a7f37; --warn: #b7791f; --bad: #c0392b; --info: #2563eb;
  --c-weekend: #e3e6ea; --c-holiday: #bcd7f5; --c-leave: #fbe98a; --c-inactive: #4b5563;
  --x: #1a7f37; --o: #8a94a3; --v: #6d28d9; --z: #c0392b; --a: #d97706; --e: #3b8577;
  --radius: 14px; --shadow: 0 1px 2px rgba(30,27,60,.04), 0 4px 16px rgba(30,27,60,.06);
  font-family: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px; }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- layout */
#app { display: flex; min-height: 100vh; }
#side { width: 236px; background: linear-gradient(180deg, #38324f 0%, #2d2842 100%); color: #dbe4f0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
#side .brand { padding: 18px 18px 12px; font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .3px; }
#side .brand small { display: block; font-weight: 400; font-size: 11px; color: #9fb3cc; margin-top: 2px; }
#side nav { flex: 1; overflow-y: auto; padding: 4px 8px; }
#side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; transition: background .15s; color: #dbe4f0; text-decoration: none; margin: 1px 0; }
#side nav a:hover { background: rgba(255,255,255,.07); }
#side nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #6cc3b1; }
#side nav a svg { opacity: .85; flex-shrink: 0; }
#side nav a .badge { margin-left: auto; }
#side nav .sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #8aa2c0; padding: 14px 10px 4px; }
#side .me { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; }
#side .me a { color: #b8c8dc; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#top { display: none; }
#view { padding: 20px 24px 60px; max-width: 1600px; width: 100%; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  #side { position: fixed; z-index: 50; left: -260px; transition: left .2s; width: 250px; }
  #side.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  #top { display: flex; align-items: center; gap: 10px; background: var(--navy); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 40; }
  #top button { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 4px; }
  #view { padding: 14px 12px 80px; }
}

/* ---------- components */
.card { background: var(--card); border: 1px solid #eceef3; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.kpi .v { font-size: 30px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
a.card { transition: transform .15s, box-shadow .15s; } a.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(30,27,60,.1); }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); } .kpi.ok .v { color: var(--ok); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #dfe2ea; background: #fff; padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; font-weight: 500; text-decoration: none; color: inherit; transition: background .15s, box-shadow .15s; }
.btn:active { transform: translateY(1px); }
.btn:hover { background: #f3f5f8; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(70,63,99,.25); }
.btn.primary:hover { background: var(--navy-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(59,133,119,.25); }
.btn.danger { color: var(--bad); border-color: #f0c4be; }
.btn.danger:hover { background: #fdf0ee; }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { padding: 4px 8px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: #eef1f5; color: #4a5562; }
.badge.ok { background: #e3f4e8; color: var(--ok); } .badge.warn { background: #fdf3dc; color: #8a5a00; }
.badge.bad { background: #fbe6e3; color: var(--bad); } .badge.info { background: #e3ecfd; color: var(--info); }
.badge.navy { background: var(--navy); color: #fff; }
label.f { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=month], input[type=week], select, textarea {
  width: 100%; border: 1px solid #d9dce5; border-radius: 10px; padding: 8px 11px; background: #fff; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(59,133,119,.35); border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
.inline input, .inline select { width: auto; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 140px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs button.on { color: var(--navy); border-color: var(--navy); }

table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th, table.t td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; z-index: 1; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: #f6f9fc; }
table.t tr.dim td { color: #9aa4b1; }
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; max-height: calc(100vh - 230px); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- modal / toast */
#modal-root .back { position: fixed; inset: 0; background: rgba(30,27,50,.45); backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 18px; overflow: hidden; width: 100%; max-width: 720px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 1100px; } .modal.narrow { max-width: 440px; }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 16px 18px; max-height: calc(100vh - 200px); overflow-y: auto; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal footer .left { margin-right: auto; display: flex; gap: 8px; }
.danger-box { background: #fdf0ee; border: 1px solid #f0c4be; color: #7a1f14; border-radius: 8px; padding: 10px 12px; }
.warn-box { background: #fdf6e3; border: 1px solid #f1dca4; color: #6b4a00; border-radius: 8px; padding: 10px 12px; }
.info-box { background: var(--accent-2); border: 1px solid #bfe3e3; color: #0b5c5d; border-radius: 8px; padding: 10px 12px; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #2d2842; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); display: flex; gap: 14px; align-items: center; max-width: 92vw; }
.toast.err { background: var(--bad); }
.toast button { background: none; border: 0; color: #7fdcdc; font-weight: 700; cursor: pointer; padding: 0; }

/* ---------- login */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #463f63, #3b8577); padding: 20px; }
#login .card { width: 100%; max-width: 380px; padding: 28px; }
#login h1 { margin-bottom: 2px; }

/* ---------- pointage grid */
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 16px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.12); display: inline-block; }
.pg-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; max-height: calc(100vh - 250px); }
table.pg { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.pg th, table.pg td { border-right: 1px solid #edf0f3; border-bottom: 1px solid #edf0f3; padding: 0; height: 26px; }
table.pg thead th { position: sticky; top: 0; z-index: 3; background: #f8fafc; font-weight: 600; color: #4a5562; text-align: center; min-width: 27px; }
table.pg thead th.we { background: var(--c-weekend); } table.pg thead th.hol { background: var(--c-holiday); }
table.pg thead th.today { box-shadow: inset 0 -3px 0 var(--accent); }
table.pg .sticky { position: sticky; left: 0; background: #fff; z-index: 2; }
table.pg thead .sticky { z-index: 4; background: #f8fafc; }
table.pg td.name { min-width: 300px; max-width: 360px; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
table.pg td.name .al { color: var(--muted); font-size: 11px; margin-right: 6px; display: inline-block; min-width: 44px; }
table.pg tr.grp td { background: #eef2f7; font-weight: 700; color: var(--navy); padding: 4px 8px; height: 24px; position: sticky; left: 0; }
table.pg td.cell { width: 27px; min-width: 27px; text-align: center; cursor: pointer; font-weight: 700; user-select: none; position: relative; }
table.pg td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
table.pg td.cell.sel { outline: 2px solid var(--navy); outline-offset: -2px; }
td.cell.we, .chip.we { background: var(--c-weekend); }
td.cell.hol, .chip.hol { background: var(--c-holiday); }
td.cell.leave, .chip.leave { background: var(--c-leave); }
td.cell.inactive, .chip.inactive { background: repeating-linear-gradient(45deg, #d1d5db, #d1d5db 3px, #f3f4f6 3px, #f3f4f6 6px); cursor: not-allowed; }
td.cell.plan::after, .chip.plan::after { content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--navy-2); opacity: .45; right: 3px; top: 3px; }
td.cell.note::before, .chip.note::before { content: ""; position: absolute; right: 0; bottom: 0; border: 4px solid transparent; border-right-color: var(--warn); border-bottom-color: var(--warn); }
td.cell.anom { box-shadow: inset 0 0 0 2px var(--bad); }
td.tot { padding: 0 6px !important; text-align: right; color: var(--muted); min-width: 34px; }
.code-X { color: var(--x); } .code-O { color: var(--o); } .code-V { color: var(--v); } .code-Z { color: var(--z); } .code-A { color: var(--a); } .code-E { color: var(--e); }
.cpick { position: fixed; z-index: 120; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 10px; width: 270px; }
.cpick .codes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.cpick .codes button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 4px; cursor: pointer; font-size: 12px; }
.cpick .codes button b { display: block; font-size: 15px; }
.cpick .codes button.on { border-color: var(--navy); background: #eef2f7; }

/* ---------- week (gsm) */
.wk-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.wk-card { background: #fff; border: 1px solid #eceef3; border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.wk-card .nm { font-weight: 600; line-height: 1.25; }
.wk-card .meta { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.chip { position: relative; border: 1px solid #dfe2ea; border-radius: 12px; height: 50px; transition: transform .1s; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; background: #fff; user-select: none; -webkit-tap-highlight-color: transparent; }
.chip .d { font-size: 10.5px; color: var(--muted); line-height: 1; }
.chip .c { font-size: 17px; font-weight: 800; line-height: 1.1; min-height: 19px; }
.chip.today { border-color: var(--accent); border-width: 2px; }
.wk-card.done { border-left: 4px solid var(--ok); }
.sticky-bottom { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; z-index: 5; }

/* ---------- calendar (verlof) */
.ycal { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.mcal h4 { margin: 0 0 4px; font-size: 13px; }
.mcal .g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.mcal .g div { text-align: center; font-size: 11.5px; padding: 4px 0; border-radius: 4px; }
.mcal .g .h { color: var(--muted); font-weight: 600; font-size: 10.5px; }
.mcal .g .d { cursor: pointer; background: #f6f8fa; }
.mcal .g .d.we { background: var(--c-weekend); }
.mcal .g .d.hol { background: var(--c-holiday); }
.mcal .g .d.lv { background: var(--c-leave); font-weight: 700; }
.mcal .g .d.sel { background: #f5b301; color: #fff; font-weight: 700; }

.diff { font-size: 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; margin-top: 6px; }
.diff .k { color: var(--muted); }
.diff del { color: var(--bad); } .diff ins { color: var(--ok); text-decoration: none; }
.bar { height: 8px; background: #edf0f3; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.photo-split { display: grid; grid-template-columns: minmax(300px, 45%) 1fr; gap: 12px; }
.photo-split .ph { position: sticky; top: 10px; max-height: calc(100vh - 120px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #111; }
.photo-split .ph img { width: 100%; display: block; transform-origin: 0 0; }
@media (max-width: 900px) { .photo-split { grid-template-columns: 1fr; } }

/* ---------- print */
#print-root { display: none; }
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; }
  #app, #login, #modal-root, #toasts { display: none !important; }
  #print-root { display: block !important; }
  .pp { page-break-after: always; font-family: Arial, sans-serif; color: #000; }
  .pp:last-child { page-break-after: auto; }
  .pp .ph { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 4px; }
  .pp .ph h1 { font-size: 15px; margin: 0; }
  .pp .ph .code { font-family: monospace; font-size: 11px; border: 1px solid #000; padding: 2px 6px; }
  .pp .lg { font-size: 9px; margin-bottom: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
  .pp .lg span { display: inline-flex; gap: 3px; align-items: center; }
  .pp table { border-collapse: collapse; width: 100%; table-layout: fixed; }
  .pp th, .pp td { border: 0.6px solid #555; font-size: 8.5px; height: 4.7mm; padding: 0 2px; overflow: hidden; white-space: nowrap; text-align: center; }
  .pp th { font-size: 7.5px; height: auto; padding: 1px 0; }
  .pp td.n { text-align: left; text-overflow: ellipsis; }
  .pp td.a { font-size: 7.5px; }
  .pp tr.g td { background: #e6e6e6 !important; font-weight: bold; text-align: left; }
  .pp .we { background: #d9d9d9 !important; } .pp .hol { background: #9ec5ee !important; }
  .pp .leave { background: #ffef75 !important; } .pp .inactive { background: #444 !important; }
  .pp .plan { font-size: 7px; color: #777; }
  .pp .foot { font-size: 9px; margin-top: 6px; display: flex; justify-content: space-between; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.chip:active { transform: scale(.94); }
.chip .c.code-X::before { content: ""; }
.tabs button { border-radius: 8px 8px 0 0; }
.page-head .sub { max-width: 760px; }
@media (max-width: 600px) {
  h1 { font-size: 20px; }
  .page-head .actions { margin-left: 0; }
  .toolbar > * { flex: 1 1 140px; }
  .toolbar input[type=search] { max-width: none; }
  .sticky-bottom .btn { flex: 1; justify-content: center; }
}
.reg-split { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 12px; align-items: start; }
@media (max-width: 1200px) { .reg-split { grid-template-columns: 1fr; } }
.pp { padding-right: 2mm; }
