@font-face {
  font-family: "Space Grotesk";
  src: url("./space-grotesk.woff2") format("woff2");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #050f0a;
  --surface: #0b1c13;
  --surface-2: #142a1d;
  --surface-hi: #0e2117;
  --border: #294233;
  --text: #e6f3e8;
  --text-2: #b9d2bd;
  --muted: #91aa98;
  --accent: #2a7449;
  --accent-2: #84a98b;
  --accent-ink: #ffffff;
  --green: #578f6b;
  --danger: #fb7185;
  --bar: #578f6b;
  --today: #173324;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 15% 12%, rgb(42 116 73 / .24), transparent 45%),
    radial-gradient(ellipse at 85% 82%, rgb(0 87 45 / .18), transparent 40%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 "Space Grotesk", Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: #a1c1a7; }
h2 { font-size: 17px; margin: 0 8px; }
h3 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; padding: 12px; }
.spacer { flex: 1; }
.error { color: var(--danger); min-height: 1em; }

/* header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: rgb(5 15 10 / .88); border-bottom: 1px solid var(--border); flex-wrap: wrap; backdrop-filter: blur(18px); }
.brand { color: var(--text); font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.brand-logo-frame { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 112px; width: 112px; height: 58px;
  border: 0; background: transparent; }
.brand-logo-frame img { display: block; flex: none; width: 92px; height: auto; max-width: 100%; opacity: 1; filter: drop-shadow(0 0 16px rgb(87 143 107 / .2)); }
.brand-name { letter-spacing: -.02em; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button { border: 1px solid transparent; background: none; color: var(--text-2); padding: 8px 12px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.active { background: rgb(87 143 107 / .18); border-color: rgb(132 169 139 / .3); color: #c3dcc7; font-weight: 600; }
.who { margin-left: auto; font-size: 13px; }
.who { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.role-badge { padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--text-2); font-size: 11px; }
.logout-form { margin: 0; display: inline-flex; }
.notice { border-left: 3px solid var(--accent-2); background: var(--surface-2); border-radius: 6px; padding: 12px 15px; color: var(--text-2); font-size: 13px; margin: 0 0 16px; }
[hidden] { display: none !important; }
:disabled { opacity: .7; cursor: not-allowed; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

/* controls */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; transition: background .16s, border-color .16s, transform .16s; }
.btn:hover { background: var(--surface-2); border-color: #578f6b; }
.btn.primary { background: linear-gradient(135deg, #2a7449, #00572d); border-color: #578f6b; color: #f8f8f8; font-weight: 600; box-shadow: 0 7px 20px rgb(0 87 45 / .2); }
.btn.primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn.danger { color: var(--danger); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-hi); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; max-width: 100%; }
input[type=search] { min-width: 220px; }
button, input, select, textarea, a { accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
label.inl { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

/* planning: six-day board, with fixed time bands inside each day */
.week { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.day { min-width: 0; overflow: hidden; background: linear-gradient(155deg, #0d2116, #09170f); border: 1px solid #31503b; border-radius: 13px; display: flex; flex-direction: column; box-shadow: 0 7px 22px rgb(0 0 0 / .12); }
.day.today { border-color: #83a98b; box-shadow: inset 0 2px #83a98b, 0 8px 24px rgb(0 0 0 / .16); }
.day-h { min-height: 46px; padding: 10px 13px; background: rgb(87 143 107 / .12); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.day-h b { text-transform: capitalize; font-size: 15px; letter-spacing: -.01em; }
.day-total { color: #c2d9c6; background: rgb(87 143 107 / .2); border: 1px solid rgb(132 169 139 / .22); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-slots { display: flex; flex-direction: column; gap: 8px; padding: 9px; }
.day-slot { min-width: 0; overflow: hidden; border: 1px solid #263f30; border-radius: 9px; background: #0a1910; }
.slot-morning { border-left: 3px solid #719c7b; }
.slot-afternoon1 { border-left: 3px solid #a19e70; }
.slot-afternoon2 { border-left: 3px solid #7497a0; }
.slot-unclassified { border-left: 3px solid #c68f66; background: #1c1711; }
.slot-head { min-height: 39px; padding: 7px 9px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; border-bottom: 1px solid rgb(185 210 189 / .12); }
.slot-head b { min-width: 0; color: #d9e8dc; font-size: 12px; font-weight: 650; }
.slot-head span { color: var(--muted); font-size: 11px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.slot-head i { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; border-radius: 50%; background: rgb(87 143 107 / .2); color: #c4dec9; font-size: 10px; font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot-unclassified .slot-head i { background: rgb(198 143 102 / .2); color: #e9bd9b; }
.slot-list { display: flex; flex-direction: column; gap: 6px; padding: 7px; }
.slot-empty { padding: 7px 8px; color: #829b88; font-size: 11px; }
.day-add { margin: 0 9px 10px; border: 1px dashed #46624e; background: transparent; color: #b6cfbb; border-radius: 8px; padding: 8px; cursor: pointer; font: inherit; font-size: 12px; transition: background .16s, border-color .16s, color .16s; }
.day-add:hover { background: rgb(87 143 107 / .12); border-color: #82a88a; color: var(--text); }
.rdv { min-width: 0; border: 1px solid #294333; border-left: 3px solid var(--c, var(--border)); border-radius: 7px; padding: 8px 9px; background: #102319; cursor: pointer; transition: transform .16s, border-color .16s, background .16s; }
.rdv.annule { opacity: 1; border-color: #a44747; border-left-color: #ef4444; background: #2a1115; }
.rdv.annule .p { color: #fecaca; text-decoration: line-through; }
.rdv.annule .rdv-time { color: #fecaca; }
.rdv.annule .rdv-status { border-color: #ef4444; color: #fca5a5; background: #601d26; }
.rdv:hover, .rdv:focus-visible { transform: translateY(-1px); border-color: #73947a; border-left-color: var(--c, #73947a); background: #142b1d; }
.rdv.annule:hover, .rdv.annule:focus-visible { border-color: #ef4444; border-left-color: #ef4444; background: #3a141a; }
.rdv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rdv-heading { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.rdv-time { color: #c4dec9; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rdv .p { min-width: 0; color: #edf5ee; font-weight: 650; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.rdv-status { flex: 0 0 auto; max-width: 46%; overflow: hidden; text-overflow: ellipsis; padding: 2px 7px; border: 1px solid var(--c, var(--border)); border-radius: 999px; color: #d8e6da; background: color-mix(in srgb, var(--c, transparent) 18%, transparent); font-size: 10px; line-height: 1.35; white-space: nowrap; }
.rdv-assignments { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; margin-top: 7px; }
.rdv-assignee { min-width: 0; display: flex; flex-direction: column; gap: 1px; color: #c2d6c6; font-size: 11px; }
.rdv-assignee b { overflow-wrap: anywhere; font-size: 12px; font-weight: 550; }
.rdv-label { color: #829b88; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; }
.rdv-city { margin-top: 5px; color: #a8c0ad; font-size: 11px; overflow-wrap: anywhere; }
.rdv-readonly { margin-top: 6px; color: #8ea793; font-size: 10px; }
.rdv .quick { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 5px; margin-top: 7px; }
.rdv .quick select { width: 100%; min-width: 0; padding: 5px 6px; font-size: 11px; }
.week[aria-busy="true"] { opacity: .72; }
.day-skeleton { min-height: 245px; padding: 14px; gap: 12px; }
.skeleton-line, .skeleton-block { border-radius: 6px; background: #1b3525; animation: planning-pulse 1.4s ease-in-out infinite alternate; }
.skeleton-line { width: 55%; height: 18px; }
.skeleton-block { height: 70px; }
.skeleton-block.short { height: 48px; width: 82%; }
@keyframes planning-pulse { to { opacity: .55; } }
.planning-error { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 22px; border: 1px solid #72463a; border-radius: 12px; background: #211710; color: #f0d6c6; }
.planning-error span { color: #c5a895; }
.mobile-day-nav { display: none; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--c, var(--border)); color: var(--text); background: color-mix(in srgb, var(--c, transparent) 16%, transparent); white-space: nowrap; }

/* tables */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); }
.grid th, .grid td { padding: 7px 9px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.grid th { font-size: 12px; color: var(--text-2); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.grid tbody tr:hover { background: var(--surface-2); }
#lsTable tbody tr { cursor: pointer; }
.grid.stats td.n, .grid.stats th.n { text-align: right; font-variant-numeric: tabular-nums; }
.grid.stats td.z { color: var(--muted); }
.grid.stats tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.barcell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.barcell i { display: block; height: 10px; border-radius: 0 4px 4px 0; background: var(--bar); }
.barcell span { font-variant-numeric: tabular-nums; font-weight: 600; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--text-2); font-size: 13px; }
.kpi .s { color: var(--muted); font-size: 12px; }

/* daily chart */
.daychart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--border); position: relative; }
.daychart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; min-width: 4px; }
.daychart .col i { display: block; background: var(--bar); border-radius: 4px 4px 0 0; }
.daychart .col:hover i { filter: brightness(1.15); }
.daychart .col .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 4px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap; z-index: 2; pointer-events: none; }
.daychart .col:hover .tip { display: block; }
.dayaxis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* params */
.params { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.reflist { list-style: none; padding: 0; margin: 0 0 12px; max-height: 420px; overflow: auto; }
.reflist li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.reflist li.off .nm { color: var(--muted); text-decoration: line-through; }
.reflist .nm { flex: 1; cursor: text; }
.reflist input[type=color] { width: 28px; height: 24px; padding: 0; border: 0; background: none; }
.addref { display: flex; gap: 6px; }
.addref input { flex: 1; }
.account-form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.account-form label { display: flex; flex-direction: column; gap: 7px; color: var(--text-2); }
.account-form input, .account-form select { min-height: 42px; }
.password-shell { width: min(480px, 100%); padding: 0; display: flex; flex-direction: column; align-items: center; gap: 20px; }

/* dialog */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
#rdvForm { padding: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--text-2); font-size: 13px; }
.form-grid .full { grid-column: 1 / -1; }
.dlg-actions { display: flex; gap: 8px; margin-top: 12px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* connexion */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 40px 24px; }
.login-shell { width: min(1080px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); align-items: center; gap: clamp(48px, 9vw, 132px); }
.login-intro { display: flex; flex-direction: column; align-items: flex-start; gap: 26px; }
.login-intro .brand-logo-frame { flex: none; width: min(440px, 100%); height: 230px;
  background: radial-gradient(ellipse closest-side, rgb(87 143 107 / .2), rgb(42 116 73 / .08) 60%, transparent 100%); }
.login-intro .brand-logo-frame img { width: 340px; }
.login-kicker { margin: 0; color: #a1c1a7; font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.login-intro h1 { margin: 7px 0 0; font-size: clamp(30px, 4vw, 46px); line-height: 1.08; letter-spacing: -.05em; }
.login-lead { max-width: 390px; margin: 12px 0 0; color: var(--text-2); font-size: 17px; }
.login-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.login-pills span { padding: 5px 11px; border: 1px solid #294233; border-radius: 999px; color: #b9d2bd; background: rgb(11 28 19 / .7); font-size: 12px; }
.login-card { width: 100%; background: linear-gradient(155deg, rgb(14 33 23 / .92), rgb(7 20 13 / .96)); border: 1px solid #294233; border-radius: 16px; padding: 30px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 24px 80px rgb(0 0 0 / .25), 0 0 46px rgb(42 116 73 / .08); }
.login-card h2 { margin: 6px 0 7px; font-size: 21px; letter-spacing: -.025em; }
.login-card-head p:last-child { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 7px; color: #c3dcc7; font-size: 13px; }
.login-card input, .login-card select { width: 100%; min-height: 46px; padding: 10px 12px; border-color: #294233; border-radius: 9px; background: #07140d; }
.login-card .btn { min-height: 46px; margin-top: 1px; border-radius: 9px; }
.login-note { margin: 0; color: #91aa98; text-align: center; font-size: 11px; }

/* responsive */
@media (max-width: 1100px) { .week { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  main { padding: 12px 16px; }
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .week.is-mobile-planning > .day[data-date]:not(.mobile-day-active) { display: none; }
  .week.is-mobile-planning { touch-action: pan-y pinch-zoom; }
  .mobile-day-nav { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; gap: 10px; width: min(100%, 520px); margin: -3px auto 12px; }
  .mobile-day-nav button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 36px; border: 1px solid #36533f; border-radius: 9px; background: #102319; color: #d6e6d9; font: 600 20px/1 "Space Grotesk", sans-serif; cursor: pointer; transition: background .16s, border-color .16s, opacity .16s; }
  .mobile-day-nav button:hover:not(:disabled) { background: #183324; border-color: #83a98b; }
  .mobile-day-nav button:disabled { opacity: .38; cursor: not-allowed; }
  .mobile-day-indicator { color: #d6e6d9; text-align: center; font-size: 13px; font-weight: 600; }
  .mobile-day-indicator::first-letter { text-transform: uppercase; }
  .day-slots { padding: 8px; }
  .slot-head { grid-template-columns: minmax(0, 1fr) auto auto; }
  .rdv { padding: 9px 10px; }
  .rdv .p { font-size: 15px; }
  .who { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  input[type=search] { min-width: 0; width: 100%; }
  h2 { width: 100%; margin: 4px 0 0; order: 5; }
  .login-body { padding: 24px 16px; }
  .login-shell { max-width: 440px; grid-template-columns: 1fr; gap: 26px; }
  .login-intro { align-items: center; gap: 16px; text-align: center; }
  .login-intro .brand-logo-frame { width: 300px; height: 160px; }
  .login-intro .brand-logo-frame img { width: 270px; }
  .login-lead { margin-top: 8px; font-size: 15px; }
  .login-pills { justify-content: center; }
  .login-card { padding: 24px; }
}
