:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --soft: #f6f7f9;
  --accent: #344155;
  --accent-soft: #e8ebf0;
  --ok: #2f6b3a;
  --ok-bg: #e6f2e8;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #a3261f;
  --bad-bg: #fbe5e3;
  --idle: #6b7280;
  --idle-bg: #f1f2f4;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #fff; color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Layout */
.top { border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.top-in { max-width: 1100px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--accent); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.nav a.on, .nav a:hover { color: var(--accent); background: var(--accent-soft); }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.head select { width: auto; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* Cards & KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--muted); }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* Grille des mois */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.month { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.month:hover { border-color: var(--accent); }
.month .p { font-weight: 600; font-size: 13px; }
.month .a { font-size: 13px; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-top: 4px; }
.s-paye { color: var(--ok); background: var(--ok-bg); }
.s-partiel { color: var(--warn); background: var(--warn-bg); }
.s-retard { color: var(--bad); background: var(--bad-bg); }
.s-a_venir { color: var(--idle); background: var(--idle-bg); }
.s-quittance { color: var(--accent); background: var(--accent-soft); }

/* Tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--soft); font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.act { white-space: nowrap; text-align: right; }
.strike td { color: var(--muted); text-decoration: line-through; }

/* Forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 10px; background: #fff; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.check input { width: auto; }
.locaux-edit { display: grid; gap: 8px; }
.locaux-edit .row { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; justify-content: space-between; }
.locaux-edit select { width: auto; }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal-box .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); }
.toast.err { background: var(--bad); }
.toast[hidden] { display: none; }

/* Login */
.login { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login .card { padding: 24px; }
.login form { display: grid; gap: 12px; }

.note { background: var(--soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.empty { padding: 20px; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  .top-in { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  #logout { margin-left: auto; }
  .kpi .v { font-size: 19px; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
  h1 { font-size: 20px; }
}
@media print { .top, .btn { display: none; } }
