:root {
  --brand: #1f4e5f;
  --brand-2: #2f6f84;
  --accent: #d9822b;
  --bg: #f5f3ef;
  --card: #ffffff;
  --ink: #1d2327;
  --muted: #6b747a;
  --line: #e4e0d8;
  --ok: #2e7d4f;
  --warn: #b26a00;
  --err: #b3261e;
  --c-wit: #2f6f84;
  --c-bdc: #3b5bdb;
  --c-abb: #e0566b;
  --c-dir: #7a8a3a;
  --c-ota: #8a63d2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(0,0,0,.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); }
button, input, select, textarea { font: inherit; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #dfe9ea 0, transparent 60%), var(--bg); }
.login { width: 100%; max-width: 380px; background: var(--card); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); }
.login .mark { width: 48px; height: 48px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: .5px; margin-bottom: 18px; }
.login h1 { font-size: 22px; margin: 0 0 4px; }
.login p.sub { margin: 0 0 22px; color: var(--muted); }
label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #3a4348; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-2); }
.btn.block { width: 100%; margin-top: 20px; padding: 12px; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.ghost:hover { background: #fff; border-color: var(--brand); }
.btn.danger { background: transparent; color: var(--err); border: 1px solid #efc9c6; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.error { color: var(--err); font-size: 14px; margin-top: 12px; min-height: 1em; }
.demo-hint { margin-top: 18px; font-size: 12.5px; color: var(--muted); background: #f7f6f2; padding: 10px 12px; border-radius: 10px; }

/* ---------- Structure ---------- */
header.top { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; }
.top-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 12px 18px; }
.top .brand { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .brand small { display: block; font-weight: 400; opacity: .75; font-size: 12px; }
.top .who { font-size: 13px; opacity: .9; }
.top button { background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 13px; }
.top button:hover { background: rgba(255,255,255,.22); }
nav.tabs { background: var(--brand); }
.tabs-inner { max-width: 1100px; margin: 0 auto; display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.tabs a { color: rgba(255,255,255,.75); text-decoration: none; padding: 10px 12px 12px; font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: #fff; border-color: var(--accent); }
.banner { background: #fff4e5; color: #6b4200; font-size: 13px; text-align: center; padding: 7px 12px; }
.banner.admin { background: #e8f1f3; color: var(--brand); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
h2 { font-size: 22px; margin: 6px 0 16px; }
h3 { font-size: 16px; margin: 0 0 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { width: auto; min-width: 160px; padding: 8px 10px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Séjours ---------- */
.stay { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.stay:first-child { border-top: 0; }
.date-chip { text-align: center; background: #f1efe9; border-radius: 10px; padding: 6px 0; line-height: 1.1; }
.date-chip b { display: block; font-size: 19px; }
.date-chip span { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.stay .t { font-weight: 600; }
.stay .amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.stay .amt small { display: block; font-weight: 400; color: var(--muted); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef2f3; color: var(--brand); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.empty { text-align: center; color: var(--muted); padding: 26px 0; }

/* ---------- Calendrier ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head h3 { margin: 0; flex: 1; text-align: center; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: 10px; overflow: hidden; user-select: none; }
.cal .dow { font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: center; padding: 6px 0; background: #faf9f6; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-transform: uppercase; }
.cal .day { position: relative; min-height: 64px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 5px; background: #fff; cursor: pointer; }
.cal .day.out { background: #faf9f6; color: #b9bdbf; cursor: default; }
.cal .day.past { background: #faf9f6; cursor: default; }
.cal .day .n { font-size: 12.5px; font-weight: 600; position: relative; z-index: 2; }
.cal .day.today .n { background: var(--accent); color: #fff; border-radius: 6px; padding: 0 5px; }
.cal .day.sel { background: #fff1e0; }
.cal .bar { position: absolute; left: 0; right: 0; bottom: 8px; height: 22px; color: #fff; font-size: 11px; font-weight: 600; padding: 3px 6px; white-space: nowrap; overflow: hidden; z-index: 1; }
.cal .bar.start { left: 50%; border-top-left-radius: 11px; border-bottom-left-radius: 11px; }
.cal .bar.end { right: 50%; border-top-right-radius: 11px; border-bottom-right-radius: 11px; }
.cal .bar.block { background: repeating-linear-gradient(45deg, #8c8f91, #8c8f91 6px, #a1a4a6 6px, #a1a4a6 12px); }
.cal .bar.bar2 { bottom: 34px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.selbar { position: sticky; bottom: 12px; margin-top: 12px; background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.selbar input { flex: 1; min-width: 140px; padding: 8px 10px; }
.selbar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.3); }

/* ---------- Revenus ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .bar-net { fill: var(--brand); }
.chart .bar-com { fill: #c9d7db; }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover + g rect { opacity: .85; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 700; padding: 8px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 10px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr.tot td { font-weight: 700; border-bottom: 0; }
table.t tr.cur td { background: #fbf7ef; }
.scroll-x { overflow-x: auto; }

/* ---------- Documents ---------- */
.doc { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.doc:first-of-type { border-top: 0; }
.doc .ic { width: 38px; height: 44px; border-radius: 6px; background: #f1efe9; display: grid; place-items: center; font-size: 10px; font-weight: 800; color: var(--brand); flex: none; }
.doc .grow { min-width: 0; }
.doc .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

/* ---------- Admin ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.secret { font-family: ui-monospace, Menlo, monospace; background: #fff4e5; padding: 2px 8px; border-radius: 6px; user-select: all; }
.status-ok { color: var(--ok); font-weight: 600; }
.status-err { color: var(--err); font-weight: 600; }
.status-warn { color: var(--warn); font-weight: 600; }
details.form { margin-top: 10px; }
details.form summary { cursor: pointer; font-weight: 600; color: var(--brand); }

/* ---------- Modale & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,28,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; }
.modal h3 { font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast { opacity: 0; pointer-events: none; position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; transition: transform .25s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--err); }

@media (max-width: 640px) {
  main { padding: 14px 12px 60px; }
  .top .who { display: none; }
  .cal .day { min-height: 52px; padding: 3px; }
  .cal .bar { font-size: 0; height: 14px; bottom: 6px; }
  .cal .bar.bar2 { bottom: 22px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kpi .v { font-size: 20px; }
  table.t { font-size: 13px; }
  table.t .hide-sm { display: none; }
}
