/* Styles communs de l'intranet */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e5e8;
  --border-strong: #cfd3d8;
  --text: #1d2125;
  --text-muted: #626a73;
  --primary: #1f5fbf;
  --primary-hover: #194f9f;
  --primary-soft: #e8f0fc;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --success: #1e8449;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
[hidden] { display: none !important; }

/* ---------- Barre supérieure ---------- */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
.brand .crumb { color: var(--text-muted); font-weight: 400; }
.topbar .spacer { flex: 1; }
.user-menu { display: flex; align-items: center; gap: 10px; color: var(--text-muted); white-space: nowrap; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #b9bec5; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { height: 28px; padding: 0 8px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; }
.btn.small.icon { width: 28px; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 500; }
.input, select.input, textarea.input {
  height: 36px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: 6px;
  font: inherit; color: var(--text); background: var(--surface);
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }

/* ---------- Messages ---------- */
.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }

.toast-zone { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1d2125; color: #fff; padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow-lg); max-width: min(560px, 90vw); pointer-events: auto;
  animation: toast-in .18s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Boîtes de dialogue ---------- */
dialog {
  border: none; border-radius: 12px; padding: 0;
  box-shadow: var(--shadow-lg); max-width: min(720px, calc(100vw - 32px));
  color: var(--text);
}
dialog::backdrop { background: rgba(16, 24, 40, 0.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-body { padding: 16px 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { border: none; background: none; padding: 8px 12px; font: inherit; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.muted { color: var(--text-muted); }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
