:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e3e6ea; --line2: #eef0f3; --text: #1b1f24; --muted: #66707b;
  --accent: #1f6feb; --accent-soft: #e7f0ff; --danger: #cf222e; --ok: #1a7f37; --warn: #9a6700;
  --shadow: 0 10px 30px rgba(20, 30, 50, .16); --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --line: #2a3038; --line2: #20252c; --text: #e6e9ed; --muted: #8e98a3;
    --accent: #4c8dff; --accent-soft: #1a2a45; --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --line: #2a3038; --line2: #20252c; --text: #e6e9ed; --muted: #8e98a3;
  --accent: #4c8dff; --accent-soft: #1a2a45; --shadow: 0 10px 30px rgba(0, 0, 0, .5); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary, a.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.icon { padding: 4px 10px; font-size: 18px; line-height: 1; }
button.danger { color: var(--danger); }
button.wide { width: 100%; padding: 9px; font-weight: 600; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
[hidden] { display: none !important; }

#app { display: flex; height: 100%; }
#side { width: 268px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand img { width: 26px; height: 26px; }
#side h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#side .grow { flex: 1; min-height: 120px; display: flex; flex-direction: column; }
#search { width: 100%; margin-bottom: 6px; }
.people { list-style: none; margin: 0; padding: 0; overflow: auto; }
.people li { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 7px; cursor: pointer; user-select: none; }
.people li:hover { background: var(--line2); }
.people .dot { width: 12px; height: 12px; border-radius: 4px; flex: none; border: 2px solid var(--c); }
.people li.on .dot { background: var(--c); }
.people .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .job { color: var(--muted); font-size: 12px; }
.people .x { opacity: 0; border: 0; padding: 0 4px; background: none; color: var(--muted); }
.people li:hover .x { opacity: 1; }
#side footer { font-size: 12px; color: var(--muted); }
#side footer a { color: var(--muted); }

/* mini mois */
#mini { user-select: none; }
#mini .mh { display: flex; align-items: center; justify-content: space-between; font-weight: 600; margin-bottom: 4px; }
#mini .mh button { border: 0; padding: 2px 8px; }
#mini .mg { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; gap: 1px; }
#mini .mg span { padding: 4px 0; border-radius: 6px; cursor: pointer; }
#mini .mg .wd { color: var(--muted); cursor: default; font-size: 11px; }
#mini .mg .out { color: var(--muted); opacity: .55; }
#mini .mg .today { color: var(--accent); font-weight: 700; }
#mini .mg .sel { background: var(--accent-soft); }
#mini .mg span:not(.wd):hover { background: var(--line2); }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
#bar h1 { font-size: 18px; margin: 0 8px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }
#bar .nav { display: flex; gap: 2px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#btnMenu, #btnNewTop { display: none; }
#banner { padding: 8px 14px; background: #fff4d6; color: #5c4300; border-bottom: 1px solid #f0d78a; }
#cal { flex: 1; min-height: 0; padding: 8px 10px 10px; }

/* FullCalendar habillage */
.fc { --fc-border-color: var(--line); --fc-page-bg-color: var(--panel); --fc-neutral-bg-color: var(--line2); --fc-today-bg-color: var(--accent-soft);
  --fc-now-indicator-color: var(--danger); --fc-list-event-hover-bg-color: var(--line2); background: var(--panel); border-radius: var(--r); }
.fc .fc-col-header-cell-cushion, .fc .fc-daygrid-day-number { color: var(--text); text-decoration: none; text-transform: capitalize; }
.fc .fc-timegrid-slot { height: 2.4em; }
.fc .fc-timegrid-slot-minor { border-top-style: dotted; }
.fc-event { border-radius: 6px; font-size: 12px; cursor: pointer; }
.fc-timegrid-event .fc-event-main { padding: 2px 4px; }
.ev { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.ev .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.ev .s { opacity: .85; font-size: 11px; }
.ev .who { display: inline-block; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 4px; background: rgba(255,255,255,.3); margin-right: 3px; }
.fc-event.tentative { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px); }
.fc-event.free { background: var(--panel) !important; color: var(--text) !important; }
.fc-event.oof { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.15) 0 4px, transparent 4px 8px); }
.fc-event.pending { background: var(--panel) !important; color: var(--text) !important; border-style: dashed !important; border-width: 2px !important; }
.fc-event.pending .fc-event-main, .fc-event.free .fc-event-main { color: var(--text); }
.fc-event.declined { opacity: .45; text-decoration: line-through; }
.fc-daygrid-dot-event .fc-event-title { font-weight: 500; }

/* vue équipe */
#team { flex: 1; overflow: auto; padding: 8px 10px 10px; }
.tg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 720px; }
.tg .tr { display: flex; border-bottom: 1px solid var(--line); min-height: 48px; }
.tg .tr:last-child { border-bottom: 0; }
.tg .tn { width: 170px; flex: none; padding: 8px 10px; border-right: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.tg .tn .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.tg .tn small { display: block; color: var(--muted); }
.tg .tl { flex: 1; position: relative; cursor: copy; }
.tg .hd .tl { cursor: default; }
.tg .hour { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line2); font-size: 11px; color: var(--muted); padding-left: 3px; }
.tg .hd .hour { border-left-color: var(--line); padding-top: 14px; }
.tg .tr:not(.hd) .hour { font-size: 0; }
.tg .blk { position: absolute; top: 6px; bottom: 6px; border-radius: 6px; color: #fff; font-size: 11px; padding: 3px 5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; background: var(--c); border: 1px solid var(--c); }
.tg .blk.tentative { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px); }
.tg .blk.free { background: var(--panel); color: var(--text); }
.tg .blk.oof { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.18) 0 4px, transparent 4px 8px); }
.tg .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.tg .ad { font-size: 11px; color: var(--muted); padding: 2px 0 0; }
.tg .off { position: absolute; top: 0; bottom: 0; background: var(--line2); opacity: .7; }

/* vue équipe verticale (téléphone) */
.tv { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: min-content; }
.tv .va { width: 38px; flex: none; position: sticky; left: 0; background: var(--panel); z-index: 3; border-right: 1px solid var(--line); }
.tv .vc { flex: 1 0 104px; border-right: 1px solid var(--line2); }
.tv .vc:last-child { border-right: 0; }
.tv .vn { position: sticky; top: 0; z-index: 2; background: var(--panel); height: 44px; padding: 4px 5px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tv .vn .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--c); margin-right: 4px; }
.tv .vn small { display: block; font-weight: 400; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; }
.tv .vb { position: relative; background-image: repeating-linear-gradient(var(--line2) 0 1px, transparent 1px 44px); cursor: copy; }
.tv .vh { position: absolute; left: 0; right: 0; font-size: 11px; color: var(--muted); text-align: right; padding-right: 4px; transform: translateY(-1px); }
.tv .blk { position: absolute; border-radius: 6px; color: #fff; font-size: 11px; line-height: 1.25; padding: 2px 4px; overflow: hidden; background: var(--c); border: 1px solid var(--c); cursor: pointer; }
.tv .blk b { font-weight: 600; }
.tv .blk.tentative { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px); }
.tv .blk.free { background: var(--panel); color: var(--text); }
.tv .blk.oof { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.18) 0 4px, transparent 4px 8px); }
.tv .vnow { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 1; }

/* panneaux */
.sheet { position: fixed; inset: 0; background: rgba(10, 15, 25, .35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.card { position: relative; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px 20px 16px; }
.card h2 { margin: 0 0 12px; font-size: 18px; }
.close { position: absolute; top: 10px; right: 10px; border: 0; }
#form { display: flex; flex-direction: column; gap: 10px; }
#form .big { font-size: 17px; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input:not([type=checkbox]) { flex: 1; }
.row label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.row label.chk, label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.when input[type=date] { flex: 1.3; } .when input[type=time] { flex: 1; }
.field { border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.field input { border: 0; padding: 4px; outline: 0 !important; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); border-radius: 20px; padding: 3px 4px 3px 10px; font-size: 13px; }
.chip button { border: 0; background: none; padding: 0 5px; }
.chip.opt { background: var(--line2); }
.chip .r { font-size: 11px; }
.note { color: var(--muted); font-size: 12px; margin: 0; min-height: 1em; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
#avail { border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.availHead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.availHead button { font-size: 12px; }
.av { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 3px 0; }
.av .n { width: 92px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av .l { flex: 1; height: 16px; position: relative; background: var(--line2); border-radius: 4px; overflow: hidden; }
.av .b { position: absolute; top: 0; bottom: 0; background: #8c959f; }
.av .b.tentative { background: #c9a227; } .av .b.oof { background: #8250df; } .av .b.free { display: none; }
.av .sel { position: absolute; top: -2px; bottom: -2px; border: 2px solid var(--accent); border-radius: 4px; }
.av .h { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.avScale { display: flex; justify-content: space-between; margin-left: 98px; font-size: 10px; color: var(--muted); }

/* détail */
.dt h2 { margin: 0 40px 4px 0; font-size: 19px; }
.dt .when { color: var(--muted); margin-bottom: 12px; }
.dt .ln { display: flex; gap: 8px; margin: 7px 0; align-items: flex-start; }
.dt .ln > span:first-child { width: 20px; flex: none; text-align: center; }
.dt .att { margin: 0; padding: 0; list-style: none; }
.dt .att li { margin: 2px 0; }
.dt .body { white-space: pre-wrap; background: var(--line2); border-radius: 8px; padding: 10px; margin-top: 10px; max-height: 260px; overflow: auto; font-size: 13px; }
.dt .tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--line2); color: var(--muted); margin-right: 4px; }
.dt .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.dt a.join { display: inline-block; background: #5b5fc7; color: #fff; text-decoration: none; border-radius: 8px; padding: 6px 12px; }
.owner { display: inline-flex; align-items: center; gap: 6px; }
.owner i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 9px 16px; border-radius: 10px; z-index: 80; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
#toast.err { background: var(--danger); color: #fff; }

/* connexion */
body.login { display: flex; align-items: center; justify-content: center; padding: 16px; }
.loginCard { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; text-align: center; max-width: 360px; width: 100%; }
.loginCard h1 { margin: 10px 0 4px; }
.loginCard p { color: var(--muted); margin: 0 0 22px; }
a.btn { display: inline-block; padding: 10px 18px; border-radius: 9px; text-decoration: none; font-weight: 600; }

/* téléphone */
#scrim { display: none; }
@media (max-width: 860px) {
  #side { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  #app.menu #side { transform: none; }
  #app.menu #scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.3); }
  #btnMenu, #btnNewTop { display: inline-block; }
  #bar { padding: 8px 10px; gap: 6px; }
  #bar h1 { order: 5; flex-basis: 100%; margin: 2px 0 0; font-size: 16px; }
  #bar .seg { order: 6; flex-basis: 100%; }
  #bar { padding-top: max(8px, env(safe-area-inset-top)); }
  .seg button { flex: 1; padding: 6px 1px; font-size: 12px; }
  #btnNewTop { margin-left: auto; }
  #cal { padding: 4px; }
  #team { padding: 4px; }
  html, body { overscroll-behavior-y: contain; }
  .tg .tn { width: 110px; font-size: 12px; }
  .when { display: grid; grid-template-columns: 1.3fr 1fr; }
  .when > span { display: none; }
  .sheet { align-items: flex-end; padding: 0; }
  .card { border-radius: 16px 16px 0 0; max-height: 92vh; }
}
