/* Police Inter hébergée par Ulyx (licence OFL, voir fonts/LICENSE-Inter.txt) : aucun appel à un service tiers */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/shared/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/shared/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #0b1220;
  --text-2: #344054;
  --muted: #667085;
  --line: #eaecf0;
  --line-strong: #d0d5dd;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #ffffff;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --warn: #b54708;
  --warn-soft: #fffaeb;
  --gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #d946ef 100%);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .18);
  --ring: 0 0 0 4px rgba(79, 70, 229, .14);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14.5px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: .98rem; font-weight: 600; margin-top: 1.25rem; }
p { margin: .4rem 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); }
.icon { display: inline-flex; flex: none; }
.icon svg { display: block; }

/* ---------- Formulaires & boutons ---------- */
input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #98a2b3; }
input:focus, select:focus { outline: none; border-color: #a5b4fc; box-shadow: var(--ring); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; padding: 0; accent-color: var(--accent); box-shadow: none; cursor: pointer; }

button, a.button, label.button {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  white-space: nowrap;
}
button:hover, a.button:hover, label.button:hover { background: var(--accent-hover); }
button:active, a.button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline: none; box-shadow: var(--ring); }
button.ghost, a.button.ghost, label.button.ghost { background: var(--surface); color: var(--text-2); border-color: var(--line-strong); font-weight: 500; }
button.ghost:hover, a.button.ghost:hover, label.button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger { background: var(--surface); color: var(--danger); border-color: #fecdca; font-weight: 500; }
button.danger:hover { background: var(--danger-soft); }
button.small, a.button.small, label.button.small, select.small { padding: .35rem .65rem; font-size: .83rem; border-radius: 8px; }
button.link { background: none; border: 0; padding: 0; box-shadow: none; color: var(--accent); font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
button.icon-only { padding: .45rem; }
button:disabled, select:disabled, input:disabled { opacity: .5; cursor: not-allowed; }
a.button.microsoft, button.microsoft { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
a.button.microsoft:hover { background: var(--surface-2); }
button.nextcloud { background: #0082c9; color: #fff; border-color: #0082c9; }
button.nextcloud:hover { background: #006aa3; }

.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row input:not([type="checkbox"]) { flex: 1 1 200px; min-width: 0; }

/* ---------- Surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card-title { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.card-title h2 { margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .12rem .55rem;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 600;
  background: #f2f4f7;
  color: var(--text-2);
  border: 1px solid var(--line);
}
.badge.admin { background: var(--accent-soft); color: var(--accent); border-color: #c7d2fe; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }

.avatar {
  display: inline-grid;
  place-items: end center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ede9fe 0%, #ddd6fe 100%);
  color: #8b5cf6;
  flex: none;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, .18);
}
.avatar svg { margin-bottom: -1px; width: 78%; height: 78%; }
.avatar.has-photo { place-items: center; background: var(--surface-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Menu utilisateur (en-tête) */
.user-menu { position: relative; }
.user-btn { display: flex; align-items: center; gap: .6rem; padding: .3rem .5rem .3rem .3rem; background: none; border: 1px solid transparent; box-shadow: none; color: var(--text); border-radius: 12px; font-weight: 400; text-align: left; }
.user-btn:hover, .user-btn.open { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.user-btn .caret { color: var(--muted); transform: rotate(90deg); transition: transform .15s; display: inline-grid; }
.user-btn.open .caret { transform: rotate(-90deg); }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 270px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .06); padding: .4rem; animation: fade .12s ease-out; }
.user-pop[hidden] { display: none; }
.user-pop-head { display: flex; align-items: center; gap: .7rem; padding: .6rem .6rem .75rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.user-pop-head .avatar { width: 42px; height: 42px; }
.user-pop-head div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.user-pop-head strong, .user-pop-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop-item { display: flex; align-items: center; justify-content: flex-start; gap: .6rem; width: 100%; padding: .55rem .6rem; background: none; border: 0; box-shadow: none; color: var(--text); border-radius: 9px; font-weight: 500; font-size: .9rem; text-align: left; }
.user-pop-item:hover { background: var(--surface-2); color: var(--text); }
.user-pop-item.danger-text { color: var(--danger, #d92d20); }
.user-pop-item.danger-text:hover { background: #fef3f2; color: var(--danger, #d92d20); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
}
/* Logotype Ulyx : violet Biodyssey, x orange */
.wordmark { font-weight: 700; letter-spacing: -.04em; color: #4421A0; line-height: 1; }
.wordmark-x { color: #FF914D; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: .9rem;
  height: 64px;
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.6rem; letter-spacing: -.02em; color: var(--text); text-decoration: none; }
.org-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: .85rem; font-weight: 500; }
.topbar .spacer { flex: 1; }
.user-btn .who { display: flex; flex-direction: column; line-height: 1.2; }
.user-btn .who strong { font-weight: 600; font-size: .9rem; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -1.5rem; padding: 0 1.5rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: .7rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafaff; }
tbody tr:last-child td { border-bottom: 0; }
tr.inactive td { opacity: .5; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button + button { margin-left: .35rem; }

/* ---------- Mot de passe temporaire ---------- */
.secret {
  margin: 1rem 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid #c7d2fe;
}
.secret-row { display: flex; gap: .5rem; align-items: center; margin: .6rem 0; flex-wrap: wrap; }
.secret code { font: 600 1.1rem/1 ui-monospace, "SF Mono", Menlo, monospace; padding: .55rem .8rem; background: var(--surface); border: 1px solid #c7d2fe; border-radius: 8px; user-select: all; letter-spacing: .04em; }

/* ---------- Notifications ---------- */
#toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; flex-direction: column; gap: .5rem; z-index: 20; }
.toast {
  display: flex; align-items: center; gap: .55rem;
  padding: .7rem 1rem; border-radius: 12px;
  background: #0b1220; color: #fff; font-weight: 500; font-size: .9rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease-out;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #32d583; flex: none; }
.toast.error::before { background: #f97066; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- États vides ---------- */
.empty { text-align: center; padding: 2.75rem 1.5rem; }
.empty-icon {
  display: inline-grid; place-items: center;
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: .9rem;
}
.empty-icon.lock { background: var(--warn-soft); color: var(--warn); }
.empty h2 { margin-bottom: .35rem; }
.empty p { max-width: 460px; margin: 0 auto 1.1rem; color: var(--muted); }

/* ---------- Écran de connexion ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-hero {
  position: relative;
  overflow: hidden;
  background: var(--gradient);
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-hero::before, .auth-hero::after { content: ""; position: absolute; border-radius: 50%; }
.auth-hero::before { width: 420px; height: 420px; background: #fff; top: -160px; right: -120px; opacity: .12; }
.auth-hero::after { width: 520px; height: 520px; background: #312e81; bottom: -260px; left: -160px; opacity: .3; }
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .brand { color: #fff; font-size: 2rem; }
.auth-hero .wordmark { color: #fff; }
.auth-hero h1 { color: #fff; font-size: 2.3rem; line-height: 1.15; max-width: 460px; letter-spacing: -.03em; }
.auth-hero p { color: rgba(255, 255, 255, .85); max-width: 440px; font-size: 1rem; }
.auth-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .7rem; }
.auth-points li { display: flex; gap: .6rem; align-items: center; color: rgba(255, 255, 255, .92); }
.auth-points .icon { background: rgba(255, 255, 255, .16); border-radius: 8px; padding: .35rem; }
.auth-foot { color: rgba(255, 255, 255, .7); font-size: .8rem; }
.auth-main { display: grid; place-items: center; padding: 2rem 16px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.auth-card form { display: flex; flex-direction: column; gap: .85rem; margin-top: 1.5rem; }
.auth-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 500; color: var(--text-2); }
.auth-card button[type="submit"] { padding: .7rem 1rem; margin-top: .25rem; }
.auth-card .error:empty { display: none; }

/* Page simple centrée (sans panneau) */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { padding: 1.5rem 16px 2rem; }
  .auth-hero h1 { font-size: 1.6rem; margin-top: 1.5rem; }
  .auth-points, .auth-foot { display: none; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: .6rem; }
  .org-chip, .user-btn .who { display: none; }
  .card { padding: 1.1rem 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  td.actions { white-space: normal; }
}

.person { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.person .avatar { width: 30px; height: 30px; font-size: .72rem; }
.page-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-xs); color: var(--accent); flex: none; }
@media (max-width: 640px) { .hide-sm { display: none; } }
.members .person, .members td:nth-child(2) { white-space: nowrap; }
@media (max-width: 1180px) { .members th:nth-child(5), .members td:nth-child(5) { display: none; } }

/* Fenêtre flottante (aperçus, formulaires) */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; z-index: 40; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }

/* ───────── Droits d'accès aux modules (ulyx : Members & access ; admin.ulyx : dépannage) ───────── */
.acc-section { margin-top: 1.5rem; }
.acc-section h3 { margin: 0 0 .35rem; font-size: 1rem; }
.acc-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .5rem; margin-top: .6rem; }
.acc-module { display: flex; align-items: center; gap: .5rem; padding: .45rem .7rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: .9rem; }
.acc-module.on { border-color: #c7d2fe; background: var(--accent-soft); color: var(--accent); }
.acc-module input { margin: 0; }
.acc-grid { min-width: 100%; }
.acc-grid th.acc-col { font-size: .72rem; line-height: 1.2; text-align: center; min-width: 58px; max-width: 84px; padding-left: .2rem; padding-right: .2rem; white-space: normal; vertical-align: bottom; }
.acc-grid td { vertical-align: middle; }
.acc-person { white-space: nowrap; }
.acc-cell { text-align: center; padding: .35rem .15rem; }
.acc-admin { text-align: center; }
.acc-pill { display: inline-block; min-width: 48px; padding: .26rem .4rem; border: 1px solid var(--line-strong); border-radius: 999px; font-size: .78rem; font-weight: 600; box-shadow: none; cursor: pointer; }
.acc-pill.static { min-width: 0; padding: .05rem .45rem; cursor: default; font-size: .72rem; }
.acc-pill.lvl-edit { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.acc-pill.lvl-view { background: var(--accent-soft); color: var(--accent); border-color: #c7d2fe; }
.acc-pill.lvl-none { background: var(--surface-2); color: var(--muted); }
button.acc-pill:hover { filter: brightness(.96); }
.acc-quick { display: block; margin-top: .3rem; font-size: .76rem; padding: .15rem .3rem; border-radius: 7px; max-width: 150px; }
.acc-person small { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.acc-log summary { cursor: pointer; font-weight: 600; }
.acc-log-row { display: grid; grid-template-columns: 150px 120px 1fr auto; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .85rem; align-items: baseline; }
@media (max-width: 720px) { .acc-log-row { grid-template-columns: 1fr; gap: .1rem; } }
