:root {
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #dfe8f7;
  --line: #c4d0e3;
  --text: #203044;
  --muted: #607087;
  --blue: #7da0d6;
  --blue-dark: #5b7cae;
  --danger: #c64747;
  --success-bg: #edf8ef;
  --success-text: #155724;
  --error-bg: #fceced;
  --error-text: #7e2121;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f5f7fb 0%, #ebf0f7 100%);
}

a {
  color: #385d90;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-shell {
  min-height: 100vh;
}

/* =========================
   HEADER / MENU PRINCIPAL
   ========================= */

.topbar {
  background: #ffffff;
  border-bottom: 1px solid #d7e0ec;
  box-shadow: 0 1px 4px rgba(20, 35, 60, 0.05);
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 12px 14px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #243b5a;
  white-space: nowrap;
}

.brand-accent {
  color: #e08a00;
  font-weight: 800;
}

.brand-text {
  color: #243b5a;
}

.topbar-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  overflow: visible;
  padding-bottom: 0;
}

.topbar-menu::-webkit-scrollbar {
  height: 8px;
}

.topbar-menu::-webkit-scrollbar-thumb {
  background: #c9d5e6;
  border-radius: 999px;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #c8d5e6;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #edf3fb);
  color: #284b73;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.topbar-link:hover {
  background: linear-gradient(180deg, #fdfefe, #e4edf9);
  border-color: #aebfd8;
  color: #1f3f67;
  text-decoration: none;
}

.topbar-link-logout {
  color: #8a2c2c;
  border-color: #ddbcbc;
  background: linear-gradient(180deg, #fffefe, #f8eaea);
}

.topbar-link-logout:hover {
  background: linear-gradient(180deg, #fffafa, #f2dfdf);
  border-color: #d4a4a4;
  color: #7a1f1f;
}

.topbar-divider {
  flex: 0 0 1px;
  align-self: stretch;
  background: #d7e0ec;
  margin: 0 4px;
}

/* =========================
   MENU ADMIN / DROPDOWN
   ========================= */
.menu-dropdown {
  position: relative;
  flex: 0 0 auto;
}

.menu-dropdown summary {
  list-style: none;
  cursor: pointer;
}

.menu-dropdown summary::-webkit-details-marker {
  display: none;
}

.topbar-link-dropdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #c8d5e6;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #edf3fb);
  color: #284b73;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.topbar-link-dropdown:hover {
  background: linear-gradient(180deg, #fdfefe, #e4edf9);
  border-color: #aebfd8;
  color: #1f3f67;
}

.topbar-link-dropdown::after {
  content: " ▾";
  font-size: 12px;
  margin-left: 6px;
}

.menu-dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: #ffffff;
  border: 1px solid #c8d5e6;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(25, 45, 80, 0.14);
  padding: 8px;
  z-index: 2000;
}

.menu-dropdown[open] .menu-dropdown-panel {
  display: block;
}

.menu-dropdown-panel a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #284b73;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.menu-dropdown-panel a:hover {
  background: #edf3fb;
  text-decoration: none;
}

/* =========================
   CONTENU
   ========================= */

.content-wrap {
  max-width: 1360px;
  margin: 16px auto;
  padding: 0 14px 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(36, 55, 87, 0.06);
}

.panel-header {
  background: linear-gradient(180deg, #ebf1fb, #d9e4f5);
  border-bottom: 1px solid var(--line);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  padding: 10px 14px;
  font-weight: bold;
}

.panel-body {
  padding: 14px;
}

.flash {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.flash-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #b7dfbf;
}

.flash-error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: #edb9b9;
}

/* =========================
   BARRES D'ACTIONS / BOUTONS
   ========================= */

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid #99aed1;
  background: linear-gradient(180deg, #f8fbff, #deebfc);
  color: #28466f;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  min-height: 36px;
}

.btn:hover,
button.btn:hover {
  filter: brightness(0.98);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(180deg, #dbe8fa, #bdd2f0);
  font-weight: bold;
}

.btn-danger {
  background: linear-gradient(180deg, #f9dddd, #f1c0c0);
  border-color: #d89a9a;
  color: #7f2b2b;
}

.btn-muted {
  background: linear-gradient(180deg, #fbfbfb, #efefef);
  border-color: #cfcfcf;
  color: #555;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3fb;
  color: #456387;
  font-size: 12px;
}

/* =========================
   GRILLES / BLOCS
   ========================= */

.grid-two {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.kpi {
  padding: 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f4f7fc);
  border: 1px solid #dbe3f0;
}

.kpi .value {
  font-size: 28px;
  font-weight: bold;
  color: #36567f;
}

.side-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.color-chip {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  display: inline-block;
}

/* =========================
   CALENDRIER
   ========================= */

.calendar-wrap {
  overflow-x: auto;
}

.calendar-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  background: white;
}

.calendar-table th {
  background: #cfe0f8;
  color: #4a6183;
  font-size: 12px;
  font-weight: bold;
  padding: 7px;
  border: 1px solid #d2dceb;
  text-align: center;
}

.calendar-table td {
  vertical-align: top;
  border: 1px solid #dce5f2;
  height: 140px;
  padding: 4px;
  background: #fcfdff;
}

.day-number {
  color: #66778d;
  font-size: 12px;
  margin-bottom: 4px;
}

.day-outside {
  background: #f1f4f8 !important;
}

.day-today {
  box-shadow: inset 0 0 0 2px #8fb1e9;
}

.event-card {
  display: block;
  padding: 4px 6px;
  margin-bottom: 4px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  line-height: 1.25;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.event-card strong {
  display: block;
  font-size: 11px;
}

.event-card .event-meta {
  opacity: 0.95;
  font-size: 10px;
}

.locked-cell {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bec8d6;
  font-size: 26px;
  font-weight: bold;
}

/* =========================
   TABLEAUX
   ========================= */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #e2e8f3;
  padding: 10px 8px;
  font-size: 13px;
  text-align: left;
}

.data-table th {
  background: #f7f9fd;
  color: #4a5e79;
}

/* =========================
   FORMULAIRES
   ========================= */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: bold;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #a9bad4;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.help {
  color: var(--muted);
  font-size: 12px;
}

/* =========================
   CARTES / CONSULTATION
   ========================= */

.consult-card {
  color: white;
  padding: 14px;
  border-radius: 0;
  margin-bottom: 2px;
}

.consult-card strong {
  display: block;
  font-size: 14px;
}

.consult-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.box-link {
  width: 92px;
  text-align: center;
  padding: 18px 10px;
  border-radius: 8px;
  background: white;
  border: 1px solid #d5dfef;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.footer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small {
  font-size: 12px;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 980px) {
  .content-wrap {
    padding: 0 10px 20px;
  }

  .grid-two {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    padding: 10px 10px;
  }

  .topbar-brand {
    font-size: 14px;
    margin-bottom: 8px;
  }

  .topbar-link {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 9px;
  }

  .topbar-divider {
    display: none;
  }

  .menu-dropdown-panel {
    right: auto;
    left: 0;
    min-width: 220px;
  }
}

@media (max-width: 980px) {
  .content-wrap {
    padding: 0 10px 20px;
  }

  .grid-two {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar-inner {
    padding: 10px 10px;
  }

  .topbar-brand {
    font-size: 14px;
    margin-bottom: 8px;
  }

  .topbar-menu {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .topbar-link,
  .topbar-link-dropdown {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 9px;
  }

  .menu-dropdown-panel {
    right: auto;
    left: 0;
    min-width: 220px;
  }
}

/* ===== FIX MENU ADMIN MOBILE ===== */

.menu-dropdown {
  position: relative;
  flex: 0 0 auto;
  width: auto !important;
}

.menu-dropdown-panel {
  display: none;
}

.menu-dropdown-panel.is-open {
  display: block !important;
  position: absolute;
  top: 45px;
  left: 0;
  min-width: 220px;
  background: #ffffff;
  border: 1px solid #c8d5e6;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  z-index: 9999;
}

button.topbar-link-dropdown {
  font: inherit;
  border: 1px solid #c8d5e6;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

@media (max-width: 980px) {
  .topbar-menu {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    gap: 6px;
    align-items: center;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .topbar-link,
  .topbar-link-dropdown {
    flex: 0 0 auto;
    min-height: 36px;
    font-size: 13px;
    padding: 6px 8px;
    white-space: nowrap;
  }

  .menu-dropdown {
    flex: 0 0 auto;
    width: auto !important;
    position: static !important;
  }

  .menu-dropdown-panel.is-open {
    display: block !important;
    position: fixed !important;
    top: 135px;
    left: 10px;
    width: 240px;
    min-width: 240px;
    background: #ffffff;
    border: 1px solid #c8d5e6;
    border-radius: 10px;
    padding: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.18);
    z-index: 999999;
  }
}

/* PAGE ADMIN MOBILE */

.admin-mobile-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-mobile-menu .btn {
  width: 100%;
  min-height: 48px;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
}

.admin-mobile-menu .btn + .btn {
  margin-top: 0;
}

/* ADMIN MOBILE VERSION LISIBLE */

.admin-mobile-menu {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px;
}

.admin-mobile-menu .btn {
  display: block !important;
  width: 100% !important;
  min-width: 100% !important;

  font-size: 16px;
  padding: 14px 10px;
  border-radius: 12px;

  text-align: center;
}