:root {
  --page: #f1f6f2;
  --paper: #ffffff;
  --ink: #102219;
  --muted: #64736b;
  --green: #17854f;
  --green-dark: #0e6f42;
  --green-soft: #eaf7ef;
  --red: #c6282f;
  --red-dark: #9e1f25;
  --red-soft: #fff1f2;
  --amber: #9a6500;
  --amber-soft: #fff7df;
  --line: #dce6e0;
  --portrait-line: #d9eee2;
  --portrait-bg: #fffafa;
  --rear-red-color: rgba(198, 40, 47, 0.30);
  --rear-green-color: rgba(23, 133, 79, 0.17);
  --motion-duration: 520ms;
  --motion-easing: cubic-bezier(.2, .78, .24, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Poppins", Arial, sans-serif;
  background:
    radial-gradient(circle at 4% 0%, rgba(198, 40, 47, .055), transparent 25rem),
    radial-gradient(circle at 98% 2%, rgba(23, 133, 79, .07), transparent 30rem),
    linear-gradient(180deg, #fdfefd 0%, var(--page) 42%, #fafcfb 100%);
}

body.modal-open { overflow: hidden; }
button, input { font: inherit; }

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  border-bottom: 1px solid rgba(220, 230, 224, .92);
  background: rgba(253, 254, 253, .91);
  backdrop-filter: blur(14px);
}

.header-inner, main, .site-footer {
  width: min(1580px, calc(100% - 32px));
  margin-inline: auto;
}

.header-inner {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-logo {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 7px 10px rgba(35, 62, 48, .14));
}

.brand-copy strong, .brand-copy small,
.header-title span, .header-title strong { display: block; }
.brand-copy strong { font-size: .98rem; }
.brand-copy small { color: var(--muted); font-size: .62rem; }
.header-title { min-width: 0; text-align: center; }
.header-title span {
  color: var(--muted);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.header-title strong {
  margin-top: 2px;
  overflow: hidden;
  font-size: .92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.login-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid rgba(23, 133, 79, .34);
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  box-shadow: 0 8px 18px rgba(23, 133, 79, .18);
  font-size: .7rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}
.login-button svg { width: 18px; height: 18px; flex: 0 0 auto; }
.login-button:hover { transform: translateY(-1px); box-shadow: 0 12px 23px rgba(23, 133, 79, .24); filter: saturate(1.05); }
.login-button:focus-visible { outline: 3px solid rgba(23, 133, 79, .18); outline-offset: 3px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  align-items: end;
  gap: 34px;
  padding: 42px 0 22px;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .16em;
}
.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -.055em;
}
.hero h1 span { color: var(--red); }
.hero-copy > p:last-child {
  max-width: 910px;
  margin: 15px 0 0;
  color: var(--muted);
  font-size: .87rem;
  line-height: 1.68;
}

.directory-tools {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .84);
  box-shadow: 0 9px 23px rgba(34, 57, 46, .07);
}
.search-box {
  height: 43px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}
.search-box:focus-within {
  border-color: rgba(23, 133, 79, .52);
  box-shadow: 0 0 0 3px rgba(23, 133, 79, .09);
}
.search-box svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--green-dark); }
.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: .75rem;
}
.search-box input:disabled { cursor: wait; }
.search-box input::placeholder { color: #93a097; }
.clear-search {
  margin-top: 9px;
  padding: 6px 9px;
  border: 0;
  border-radius: 8px;
  color: var(--red);
  background: var(--red-soft);
  font-size: .63rem;
  font-weight: 700;
  cursor: pointer;
}
.clear-search:disabled { opacity: .4; cursor: default; }

.connection-status {
  margin: 0 0 9px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.5;
}
.connection-status.is-loading { color: var(--green-dark); background: var(--green-soft); }
.connection-status.is-success { color: var(--green-dark); border-color: rgba(23, 133, 79, .3); background: var(--green-soft); }
.connection-status.is-warning { color: var(--amber); border-color: rgba(154, 101, 0, .25); background: var(--amber-soft); }
.connection-status.is-error { color: var(--red-dark); border-color: rgba(198, 40, 47, .3); background: var(--red-soft); }

.department-nav {
  position: sticky;
  z-index: 90;
  top: 79px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 13px;
  border-bottom: 1px solid rgba(220, 230, 224, .85);
  background: rgba(241, 246, 242, .91);
  backdrop-filter: blur(12px);
  scrollbar-width: thin;
}
.department-link {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, .86);
  font-size: .64rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}
.department-link:hover { transform: translateY(-1px); border-color: rgba(23, 133, 79, .38); background: var(--green-soft); }
.department-link span {
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 18px;
  padding-inline: 5px;
  border-radius: 999px;
  color: var(--red);
  background: var(--red-soft);
  font-size: .55rem;
}

.directory { padding: 10px 0 58px; }
.department-section {
  scroll-margin-top: 142px;
  padding: 31px 0 18px;
  border-bottom: 1px solid rgba(220, 230, 224, .72);
}
.department-section:last-child { border-bottom: 0; }
.department-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 15px;
}
.department-title { margin: 0; font-size: clamp(1.25rem, 2vw, 2rem); line-height: 1.05; letter-spacing: -.035em; }
.department-count {
  min-width: max-content;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: .62rem;
  font-weight: 800;
}
.employee-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(168px, 1fr));
  gap: 12px 9px;
}
.employee-concept {
  min-width: 0;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 16px;
  outline: none;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.employee-concept:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .55); }
.employee-concept:focus-visible { border-color: rgba(23, 133, 79, .44); box-shadow: 0 0 0 3px rgba(23, 133, 79, .1); }
.employee-concept.is-placeholder { cursor: default; opacity: .72; }
.employee-concept.is-placeholder:hover { transform: none; background: transparent; }
.employee-concept[hidden] { display: none; }
.employee-card { position: relative; width: 100%; aspect-ratio: 190 / 255; isolation: isolate; }
.rear-frame {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  background: transparent;
  opacity: 0;
  will-change: opacity, transform, inset, filter;
  transition: opacity 240ms ease, transform var(--motion-duration) var(--motion-easing), inset var(--motion-duration) var(--motion-easing), border-radius var(--motion-duration) var(--motion-easing), filter var(--motion-duration) var(--motion-easing);
}
.rear-frame-red {
  inset: 9px 12px 9px 8px;
  border: 1px dashed var(--rear-red-color);
  border-radius: 13px;
  transform: translate3d(0, 0, 0) rotate(-1.35deg) scale(.88, .92);
  transform-origin: center;
  filter: blur(.35px);
}
.rear-frame-green {
  inset: 9px 8px 7px 10px;
  border: 1px solid var(--rear-green-color);
  border-radius: 13px;
  transform: translate3d(0, 0, 0) rotate(.7deg) scale(.9, .93);
  transform-origin: center;
  filter: blur(.3px);
}
.employee-concept:hover .rear-frame,
.employee-concept:focus-visible .rear-frame,
.employee-concept.rear-visible .rear-frame { opacity: 1; filter: blur(0); }
.employee-concept.is-placeholder .rear-frame { display: none; }
.employee-concept:hover .rear-frame-red,
.employee-concept:focus-visible .rear-frame-red,
.employee-concept.rear-visible .rear-frame-red { inset: -1px 5px 1px -5px; border-radius: 16px; transform: translate3d(0, 0, 0) rotate(-1.35deg) scale(1); }
.employee-concept:hover .rear-frame-green,
.employee-concept:focus-visible .rear-frame-green,
.employee-concept.rear-visible .rear-frame-green { inset: 3px -2px -3px 5px; border-radius: 16px; transform: translate3d(0, 0, 0) rotate(.7deg) scale(1); }
.card-surface {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 33px 10px 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--paper);
  box-shadow: 0 9px 19px rgba(35, 62, 48, .09), 0 1px 1px rgba(35, 62, 48, .03);
  transform: translateZ(0);
  transition: transform var(--motion-duration) var(--motion-easing), box-shadow var(--motion-duration) var(--motion-easing);
}
.employee-concept:hover .card-surface,
.employee-concept:focus-visible .card-surface,
.employee-concept.rear-visible .card-surface { transform: translate3d(1px, -1px, 0); box-shadow: 0 14px 25px rgba(35, 62, 48, .13), 0 1px 1px rgba(35, 62, 48, .03); }
.employee-concept.is-placeholder .card-surface { border-style: dashed; box-shadow: none; background: rgba(255, 255, 255, .65); }
.top-line { position: absolute; z-index: 3; top: 0; height: 4px; }
.top-line-green { left: 0; width: calc(50% - 21px); border-radius: 15px 0 0 0; background: var(--green); }
.top-line-red { right: 0; width: calc(50% - 21px); border-radius: 0 15px 0 0; background: var(--red); }
.matricule {
  position: absolute;
  z-index: 5;
  top: -1px;
  left: 50%;
  width: 42px;
  height: 25px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 0 0 7px 7px;
  color: #101b16;
  background: #fff;
  box-shadow: 0 4px 8px rgba(35, 62, 48, .04);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .07em;
}
.photo-frame {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--portrait-line);
  border-radius: 11px;
  background: var(--portrait-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), 0 1px 3px rgba(35, 62, 48, .04);
}
.employee-photo { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 28%; }
.photo-frame.photo-fallback .employee-photo,
.employee-concept.is-placeholder .employee-photo { object-fit: contain; padding: 8px; }
.employee-name { margin: 7px 0 0; text-align: center; line-height: 1.12; }
.employee-name > strong, .employee-name > span { display: block; }
.employee-name > strong {
  overflow: hidden;
  color: #050906;
  font-size: 8.2px;
  font-weight: 800;
  letter-spacing: -.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.employee-name > span {
  min-height: 19px;
  margin-top: 2px;
  overflow: hidden;
  color: #050906;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: -.015em;
  line-height: 1.18;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.employee-name > span strong { font-weight: 800; }
.employee-role {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 6.3px;
  font-weight: 600;
  line-height: 1.24;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.employee-concept.is-placeholder .last-name { color: var(--muted); }

.profile-dialog {
  width: min(900px, calc(100% - 28px));
  max-width: calc(100vw - 28px);
  max-height: calc(100dvh - 36px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 28px 90px rgba(21, 43, 31, .28);
  scrollbar-width: thin;
  scrollbar-color: rgba(23, 133, 79, .35) transparent;
}
.profile-dialog::backdrop { background: rgba(15, 31, 22, .56); backdrop-filter: blur(5px); }
.profile-dialog::-webkit-scrollbar { width: 8px; height: 0; }
.profile-dialog::-webkit-scrollbar-track { background: transparent; }
.profile-dialog::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(23, 133, 79, .28); }
.profile-dialog[open] { animation: dialog-in 220ms ease-out; }
.profile-close {
  position: absolute;
  z-index: 5;
  top: 13px;
  right: 13px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, .92);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.profile-close:hover { color: var(--red); background: var(--red-soft); }
.profile-layout { width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(260px, .85fr) minmax(0, 1.4fr); }
.profile-visual {
  position: relative;
  min-height: 490px;
  display: grid;
  place-items: center;
  padding: 56px 34px;
  background: radial-gradient(circle at 20% 15%, rgba(198, 40, 47, .09), transparent 14rem), linear-gradient(145deg, #edf8f1 0%, #f8fbf9 100%);
}
.profile-avatar {
  width: min(300px, 100%);
  aspect-ratio: 1;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, .95);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 19px 38px rgba(35, 62, 48, .15);
}
.profile-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 28%; }
.profile-avatar.photo-fallback img { object-fit: contain; padding: 14px; }
.profile-matricule {
  position: absolute;
  bottom: 28px;
  left: 50%;
  padding: 7px 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  color: var(--red);
  background: var(--red-soft);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .11em;
}
.profile-content { min-width: 0; padding: 65px 44px 44px; overflow-wrap: anywhere; }
.profile-department { margin: 0; color: var(--green); font-size: .67rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.profile-content h2 { margin: 7px 0 0; font-size: clamp(1.75rem, 4vw, 3rem); line-height: 1.02; letter-spacing: -.05em; }
.profile-role { margin: 10px 0 0; color: var(--muted); font-size: .86rem; font-weight: 600; }
.profile-details { width: 100%; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 22px; margin: 34px 0 0; }
.profile-details div { min-width: 0; max-width: 100%; padding-top: 12px; border-top: 1px solid var(--line); overflow: hidden; }
.profile-details dt { color: var(--muted); font-size: .59rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.profile-details dd { min-width: 0; max-width: 100%; margin: 5px 0 0; overflow-wrap: anywhere; word-break: break-word; white-space: normal; color: var(--ink); font-size: .76rem; font-weight: 700; line-height: 1.45; }
.profile-details a { color: var(--green-dark); text-decoration: none; overflow-wrap: anywhere; word-break: break-word; }
.profile-details a:hover { text-decoration: underline; }
.empty-state { margin: 45px 0 70px; color: var(--muted); font-size: .86rem; text-align: center; }
.site-footer {
  min-height: 84px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .69rem;
}
.footer-legal { color: var(--ink); font-weight: 700; }
.footer-contacts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}
.footer-contact {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green-dark);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.footer-contact:hover { text-decoration: underline; }
.footer-contact:focus-visible { outline: 3px solid rgba(23, 133, 79, .14); outline-offset: 3px; border-radius: 6px; }
.footer-icon { width: 18px; height: 18px; flex: 0 0 auto; }
.mail-icon { color: var(--red); }
.whatsapp-icon { color: var(--green); }
.footer-separator { color: var(--line); font-weight: 800; }
.footer-total { text-align: right; font-weight: 700; }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1440px) { .employee-grid { grid-template-columns: repeat(6, minmax(168px, 1fr)); } }
@media (max-width: 1240px) { .employee-grid { grid-template-columns: repeat(5, minmax(168px, 1fr)); } }
@media (max-width: 1040px) {
  .hero { grid-template-columns: 1fr; }
  .employee-grid { grid-template-columns: repeat(4, minmax(168px, 1fr)); }
  .site-footer { grid-template-columns: 1fr; justify-items: center; gap: 11px; padding-block: 18px; text-align: center; }
  .footer-total { text-align: center; }
}
@media (max-width: 820px) {
  .header-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; }
  .header-title { text-align: center; }
  .login-button { padding-inline: 11px; }
  .login-button span { display: none; }
  .employee-grid { grid-template-columns: repeat(3, minmax(158px, 1fr)); }
  .profile-layout { grid-template-columns: 1fr; }
  .profile-visual { min-height: auto; padding: 58px 34px 72px; }
  .profile-avatar { width: min(260px, 78vw); }
  .profile-content { padding: 38px 30px 34px; }
}
@media (max-width: 610px) {
  .header-inner, main, .site-footer { width: calc(100% - 20px); }
  .header-title span { display: none; }
  .header-title strong { font-size: .78rem; }
  .brand-copy { display: none; }
  .brand-logo { width: 43px; height: 43px; }
  .login-button { min-height: 39px; padding: 8px 10px; }
  .hero { padding-top: 30px; }
  .department-nav { top: 78px; }
  .employee-grid { grid-template-columns: repeat(2, minmax(145px, 1fr)); gap-inline: 5px; }
  .department-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .profile-details { grid-template-columns: 1fr; }
  .site-footer {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 12px;
    padding-block: 20px;
    text-align: center;
  }
  .footer-contacts { flex-wrap: wrap; }
  .footer-total { text-align: center; }
}
@media (max-width: 360px) {
  .employee-grid { grid-template-columns: 1fr; }
  .employee-concept { max-width: 220px; margin-inline: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rear-frame, .card-surface, .employee-concept, .department-link { transition-duration: 1ms; }
  .profile-dialog[open] { animation: none; }
}
