/* Oscar — panneau web. Sombre, mobile d'abord, sans dépendance. */
:root {
  --bg: #0b0b12; --surface: #13131d; --surface-2: #1b1b28; --surface-3: #24243494;
  --border: #2a2a3c; --text: #ecebf5; --muted: #9a98b3; --faint: #6c6a85;
  --accent: #7c5cff; --accent-2: #a593ff; --accent-soft: #7c5cff22;
  --ok: #3ecf8e; --warn: #f5b94a; --danger: #ff5d6c; --info: #4cc2ff;
  --radius: 16px; --radius-sm: 10px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --tabbar-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
.hidden { display: none !important; }

/* ——— Structure ——— */
#app { display: flex; min-height: 100%; }
#sidebar { display: none; }
#shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 10px) calc(var(--sar) + 14px) 10px calc(var(--sal) + 14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px); border-bottom: 1px solid #ffffff0d;
}
#view-title { display: none; margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; flex: 1; }
.guild-btn {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px 5px 5px; cursor: pointer; min-width: 0; flex: 1; max-width: 340px;
}
.g-ico { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2) center/cover; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.g-txt { display: flex; flex-direction: column; min-width: 0; text-align: left; line-height: 1.15; }
.g-txt small { color: var(--muted); font-size: 11px; }
.g-txt strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); margin-left: auto; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 17px; flex: none; }
.icon-btn:active { transform: scale(.94); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); flex: none; box-shadow: 0 0 0 3px #ffffff08; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #3ecf8e2a; }
.dot.off { background: var(--danger); }
#view { flex: 1; padding: 16px calc(var(--sar) + 14px) calc(var(--tabbar-h) + var(--sab) + 24px) calc(var(--sal) + 14px); outline: none; width: 100%; max-width: 1180px; margin: 0 auto; }

/* Barre d'onglets (mobile) */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px calc(var(--sar) + 6px) calc(var(--sab) + 6px) calc(var(--sal) + 6px);
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px); border-top: 1px solid #ffffff12;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 11px; cursor: pointer; border-radius: 12px; }
.tab .ti { font-size: 21px; line-height: 1; filter: grayscale(1) opacity(.75); }
.tab.active { color: var(--text); }
.tab.active .ti { filter: none; }

@media (min-width: 900px) {
  #sidebar {
    display: flex; flex-direction: column; width: 248px; flex: none; position: sticky; top: 0; height: 100vh;
    padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface);
  }
  #tabbar { display: none; }
  #view { padding-bottom: 40px; }
  #view-title { display: block; }
  .guild-btn { flex: none; width: 280px; }
  #topbar { padding-left: 24px; padding-right: 24px; }
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 38px; height: 38px; border-radius: 11px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
#side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 0; background: none; color: var(--muted); cursor: pointer; text-align: left; font-size: 14px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item .ni { width: 22px; text-align: center; }
.side-foot { margin-top: auto; color: var(--faint); font-size: 12px; padding: 10px; }

/* ——— Blocs ——— */
.grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .grid.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .grid.three { grid-template-columns: 1fr 1fr 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.card h2 .right { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.section-gap { margin-top: 14px; }
.hero { display: flex; align-items: center; gap: 14px; }
.hero img, .hero .ph { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); object-fit: cover; flex: none; }
.hero h3 { margin: 0; font-size: 18px; }
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #3ecf8e44; background: #3ecf8e14; }
.pill.warn { color: var(--warn); border-color: #f5b94a44; background: #f5b94a14; }
.pill.danger { color: var(--danger); border-color: #ff5d6c44; background: #ff5d6c14; }
.pill.accent { color: var(--accent-2); border-color: #7c5cff55; background: var(--accent-soft); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(6, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: default; text-align: left; }
button.kpi { cursor: pointer; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.stats-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.stats-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Barres (une seule série : nombre de membres par classe) */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 128px 1fr 34px; align-items: center; gap: 10px; font-size: 13.5px; }
.bar-row .bl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; display: flex; align-items: stretch; }
.bar-fill { background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; transition: width .4s ease; }
.bar-fill:hover { background: var(--accent-2); }
.bar-row .bv { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

/* Listes */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid #ffffff0a; min-width: 0; }
.row:last-child { border-bottom: 0; }
button.row { width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; border-radius: 0; }
button.row:active { background: var(--surface-2); }
.row .av { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2) center/cover; flex: none; display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 14px; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { color: var(--muted); font-size: 12.5px; flex: none; text-align: right; }
.cdot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--faint); }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Formulaires */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=search], input[type=number], input[type=time], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: 16px; outline: none; min-width: 0;
}
textarea { resize: vertical; min-height: 84px; }
select[multiple] { min-height: 140px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar input[type=search] { flex: 1 1 200px; }
.toolbar select { flex: 0 1 220px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: #ff5d6c1c; border-color: #ff5d6c55; color: var(--danger); }
.btn.ghost { background: none; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns.end { justify-content: flex-end; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; }
.inline > .btn { flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 13px; color: var(--muted); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 9px; color: var(--muted); cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px #0006; }
.role-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.role-chip .x { border: 0; background: #ffffff10; color: var(--muted); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 13px; line-height: 1; }
.role-chip.static { padding-right: 10px; }

/* Feuille (bas d'écran sur mobile, fenêtre sur ordinateur) */
.backdrop { position: fixed; inset: 0; background: #000a; z-index: 50; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border-top-left-radius: 22px; border-top-right-radius: 22px; border: 1px solid var(--border);
  padding: 8px calc(var(--sar) + 18px) calc(var(--sab) + 20px) calc(var(--sal) + 18px); animation: up .24s cubic-bezier(.2,.8,.2,1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.sheet hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(560px, 92vw); border-radius: 20px; animation: pop .2s ease; }
  .sheet .grab { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -48%); opacity: 0; } }
.kv { display: grid; grid-template-columns: minmax(90px, 32%) 1fr; gap: 6px 12px; font-size: 14px; margin: 8px 0 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.kv dd.long { max-height: 180px; overflow-y: auto; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.warnbox { background: #f5b94a14; border: 1px solid #f5b94a44; color: var(--warn); padding: 10px 12px; border-radius: 12px; font-size: 13.5px; margin-bottom: 12px; }
.check { display: flex; gap: 10px; align-items: center; margin: 10px 0 14px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 6px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 13px; }
.more-grid .mi { font-size: 24px; }

/* Toasts */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--sab) + 14px); z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(440px, 92vw); pointer-events: none; }
@media (min-width: 900px) { #toasts { bottom: 24px; } }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 11px 14px; box-shadow: 0 8px 30px #0008; font-size: 14px; animation: up .2s ease; }
.toast.ok { border-color: #3ecf8e66; }
.toast.err { border-color: #ff5d6c88; }

/* Chat */
.chat { display: flex; flex-direction: column; height: calc(100dvh - var(--tabbar-h) - var(--sab) - var(--sat) - 110px); min-height: 360px; }
@media (min-width: 900px) { .chat { height: calc(100dvh - 120px); } }
.chat-feed { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 18px; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.msg.tool { align-self: flex-start; background: none; border: 1px dashed var(--border); color: var(--muted); font-size: 12.5px; padding: 6px 10px; }
.msg.err { align-self: flex-start; background: #ff5d6c14; border: 1px solid #ff5d6c55; color: var(--danger); }
.msg.confirm { align-self: stretch; max-width: none; background: #f5b94a0f; border: 1px solid #f5b94a55; }
.msg.confirm .kv { margin-bottom: 10px; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 4px 8px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding-top: 8px; }
.chat-form textarea { min-height: 46px; max-height: 160px; border-radius: 22px; padding: 12px 16px; }
.chat-form .btn { border-radius: 50%; width: 46px; height: 46px; padding: 0; font-size: 18px; }

/* Calendrier des absences */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 12px; }
.cal .h { color: var(--faint); text-align: center; padding-bottom: 2px; }
.cal .d { aspect-ratio: 1; border-radius: 9px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; min-width: 0; }
.cal .d.out { background: none; }
.cal .d.today { outline: 2px solid var(--accent); }
.cal .d .n { color: var(--muted); }
.cal .d .c { font-weight: 700; color: var(--text); font-size: 13px; }
.cal .d.has { background: #7c5cff33; }
.cal .d.has2 { background: #7c5cff66; }
.cal .d.has3 { background: #7c5cffaa; }

.logline { padding: 8px 2px; border-bottom: 1px solid #ffffff0a; font-size: 13.5px; }
.logline .meta { color: var(--faint); font-size: 11.5px; display: flex; gap: 8px; flex-wrap: wrap; }
pre.syslog { background: #07070c; border: 1px solid var(--border); border-radius: 12px; padding: 12px; font-size: 11.5px; overflow-x: auto; max-height: 70vh; white-space: pre-wrap; word-break: break-word; margin: 0; }
.skeleton { height: 76px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t td, table.t th { padding: 7px 6px; border-bottom: 1px solid #ffffff0a; text-align: left; }
table.t th { color: var(--muted); font-weight: 500; }
table.t td.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ——— Connexion Discord, demandes, sas (phase 2) ——— */
.row .row-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; }
.row .end.btns { flex-wrap: nowrap; }
.row.req { align-items: flex-start; }
.row.req .s { white-space: normal; }
@media (max-width: 640px) { .row.req, .row:has(.end.btns) { flex-wrap: wrap; } .row .end.btns { width: 100%; justify-content: flex-end; } }
.side-foot .me { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; color: var(--muted); }
.side-foot .me .btn { width: 100%; }
.side-foot .me .av { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2) center/cover; display: grid; place-items: center; font-size: 11px; flex: none; }
.side-foot .me span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.login #sidebar, body.login #topbar, body.login #tabbar { display: none !important; }
.login-card { max-width: 420px; margin: 12vh auto 0; text-align: center; display: grid; gap: 14px; justify-items: center; }
.login-card img { border-radius: 18px; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; text-decoration: none; }
.login-card .btns { justify-content: center; }
#ac-results:empty { display: none; }

/* ——— Tableau des activités ——— */
.acts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card.act { border-left: 4px solid var(--act, var(--accent)); display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.act-type { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--act, var(--muted)); }
.act-title { font-size: 17px; font-weight: 700; }
.act-groups { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-top: 4px; font-size: 13.5px; }
.act-gh { font-weight: 650; font-size: 12.5px; }
.act-tag { display: inline-block; font-size: 10.5px; padding: 0 5px; border-radius: 6px; background: #ffffff14; color: var(--muted); }
