:root {
  --ink: #1F2430;
  --muted: #6B7280;
  --muted-light: #9AA1AC;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --accent: #0F7DF4;
  --accent-dark: #0B62C4;
  --accent-dim: #E7F1FE;
  --accent-purple: #7C0BA0;
  --accent-red: #CE0505;
  --brand-gradient: linear-gradient(90deg, var(--accent-purple), var(--accent));
  --good: #16A34A;
  --good-dim: #E7F7ED;

  --font: 'Fira Sans Condensed', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.muted-small { color: var(--muted-light); font-size: 12.5px; margin: 2px 0 0; }

/* ---------- Login page ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  text-align: center;
}

.login-mark {
  color: var(--accent);
  font-size: 26px;
  margin-bottom: 6px;
}
.login-logo { max-width: 100%; max-height: 64px; width: auto; height: auto; margin: 0 auto 14px; display: block; }

.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }

.login-form { text-align: left; display: flex; flex-direction: column; gap: 14px; }

.login-forgot-link {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.login-forgot-link:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Shared form / alert bits ---------- */

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.field span { font-weight: 500; }

.field input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: #fff;
}

.field-icon-wrap { position: relative; }
.field-icon-wrap input {
  width: 100%;
  box-sizing: border-box;
  padding-left: 38px;
}
.field-icon-wrap input.js-password-input { padding-right: 38px; }
.field-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  display: flex;
  pointer-events: none;
}
.field-icon svg { width: 16px; height: 16px; }
button.field-icon-toggle {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
}
.field-icon-toggle:hover { color: var(--accent); background: var(--bg); }
.field-icon-toggle svg { width: 17px; height: 17px; }

select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 30px 8px 12px;
  font-size: 13.5px;
  font-family: var(--font);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  background-size: 14px;
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
select:hover { border-color: var(--muted-light); }
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background-color: #fff;
}

.alert {
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
  text-align: left;
}
.alert--error { background: #FCEBEA; color: #9C2E27; border: 1px solid #F1C2BE; }

.btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn--primary { background: var(--brand-gradient); color: #fff; }
.btn--primary:hover { filter: brightness(0.93); }
.btn--ghost { background: #fff; border-color: var(--accent); color: var(--accent); }
.btn--ghost:hover { background: var(--accent-dim); }
.btn--text { background: none; color: var(--accent); padding-left: 4px; padding-right: 4px; }
.btn--text:hover { text-decoration: underline; }
.btn--block { width: 100%; }

/* État "en cours" générique pour tout bouton CTA au submit — 3 points animés,
   même gabarit que le bouton (pas de redimensionnement au clic). */
button[data-loading="1"], .table-icon-btn[data-loading="1"] { cursor: default; opacity: 0.85; }
.btn-dots { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: btn-dots-bounce 1.2s infinite ease-in-out both;
}
.btn-dots span:nth-child(1) { animation-delay: -0.32s; }
.btn-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes btn-dots-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---------- Top bar (full width, above sidebar + content) ---------- */

.dash-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.dash-topbar-brand { display: flex; align-items: center; gap: 9px; flex-grow: 1; min-width: 0; }
.dash-topbar-logo { max-height: 36px; width: auto; height: auto; display: block; }
.dash-topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sidebar-brand-mark { color: var(--accent); font-size: 18px; }
.sidebar-brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

/* ---------- Dashboard shell ---------- */

.dash-shell { display: flex; }

.dash-sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px - 64px);
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.sidebar-link:hover { background: var(--bg); color: var(--ink); }
.sidebar-link--active { background: none; color: var(--ink); font-weight: 700; }
.sidebar-link-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sidebar-link-icon svg { width: 18px; height: 18px; }
.sidebar-link-label { flex-grow: 1; }

.sidebar-badge {
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 8px;
}

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 24px; }
.sidebar-footer .sidebar-link { border-bottom: none; }
.sidebar-link--muted { color: var(--muted-light); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }

/* ---------- Header ---------- */

.dash-content { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }

.dash-header {
  flex-shrink: 0;
  padding: 24px 28px 4px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink);
}

.dash-header-title { font-size: 21px; font-weight: 700; margin: 0; }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 18px; height: 18px; }

.account-menu { position: relative; }

.account-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  border: 2px solid #fff;
  outline: 2px solid var(--accent-dim);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.account-dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  width: 200px;
  box-shadow: 0 8px 24px rgba(20, 24, 33, 0.1);
  display: none;
  z-index: 20;
}
.account-dropdown.open { display: block; }
.account-dropdown-name { font-weight: 600; font-size: 13.5px; }
.account-dropdown-email { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.account-dropdown a {
  display: block;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration: none;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}

.notifications-menu { position: relative; }
.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #E5484D;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.notifications-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 24, 0.4);
  z-index: 200;
  display: none;
}
.notifications-panel-overlay.open { display: block; }
.notifications-panel {
  position: absolute;
  right: 0; top: 0;
  width: 360px;
  max-width: 90vw;
  height: 100%;
  background: #fff;
  box-shadow: -8px 0 32px rgba(20, 24, 33, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.notifications-panel-overlay.open .notifications-panel { transform: translateX(0); }
.notifications-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}
.notifications-panel-header h3 { margin: 0; font-size: 16px; }
.notifications-panel-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.notifications-panel-close:hover { background: var(--bg); }
.notifications-panel-body { flex: 1; overflow-y: auto; padding: 14px; }

.notification-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.45;
  border: 1px solid var(--border);
}
.notification-card:hover { background: var(--bg); }
.notification-card + .notification-card { margin-top: 10px; }
.notification-card-icon {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.notification-card-icon svg { width: 17px; height: 17px; }
.notification-card--overdue .notification-card-icon { background: #FBE9E7; color: #E5484D; }
.notification-card--exit_soon .notification-card-icon { background: #FEF3E2; color: #F5A524; }
.notification-card--new_order .notification-card-icon { background: var(--accent-dim); color: var(--accent); }
.notification-card { position: relative; opacity: 0.6; }
.notification-card--unread { opacity: 1; background: var(--bg); }
.notification-card-dot {
  position: absolute;
  top: 14px; right: 14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- Main content ---------- */

.dash-main { padding: 20px 28px 80px; max-width: 1080px; width: 100%; margin: 0 auto; flex-grow: 1; }

.dash-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  color: #fff;
  background: var(--brand-gradient);
}
.dash-footer-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dash-footer-icon {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.dash-footer-title { font-size: 14px; font-weight: 700; }
.dash-footer-subtitle { font-size: 12px; opacity: 0.85; }
.dash-footer-signature {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 600;
  opacity: 0.8;
  white-space: nowrap;
}
.dash-footer-cta {
  flex-shrink: 0;
  background: #fff;
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 999px;
  white-space: nowrap;
}
.dash-footer-cta:hover { background: var(--accent-dim); }

.dash-greeting { font-size: 14px; color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}

.card--welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 14px;
}
.card--welcome h2 { margin: 0; font-size: 18px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card-grid--2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 800px) {
  .card-grid--2 { grid-template-columns: 1fr; }
}

.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title-row h3 { margin: 0; font-size: 14.5px; font-weight: 600; }

.metric-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.metric-badge {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.metric-badge--good { background: var(--good-dim); color: var(--good); }
.metric-badge--muted { background: var(--bg); color: var(--muted); }
.metric-label { font-size: 13px; color: var(--muted); }

.empty-state { text-align: center; padding: 18px 8px; }
.empty-state-icon { font-size: 24px; }
.empty-state p { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }

.detail-list { margin: 0; }
.detail-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--muted); margin: 0; }
.detail-row dd { margin: 0; font-weight: 500; text-align: right; }

.roadmap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.roadmap-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: var(--muted-light);
}
.roadmap-item--done { color: var(--ink); }
.roadmap-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0;
}
.roadmap-item--done .roadmap-dot { background: var(--good-dim); color: var(--good); border-color: transparent; }

/* ---------- Tooltips (data-tooltip="Texte") ---------- */

[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--ink);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
  padding: 5px 9px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 450;
}
[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 450;
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
[data-tooltip]:hover::before, [data-tooltip]:focus-visible::before { opacity: 1; }

/* Dans le header, le tooltip par défaut (au-dessus) sort du viewport — on l'affiche en dessous. */
.dash-topbar-actions [data-tooltip]::after {
  bottom: auto;
  top: calc(100% + 9px);
  transform: translateX(-50%) translateY(-4px);
}
.dash-topbar-actions [data-tooltip]::before {
  bottom: auto;
  top: calc(100% + 4px);
  border-top-color: transparent;
  border-bottom-color: var(--ink);
}
.dash-topbar-actions [data-tooltip]:hover::after,
.dash-topbar-actions [data-tooltip]:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}

/* ---------- Page progress bar ---------- */

.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  z-index: 500;
  background: var(--brand-gradient);
  box-shadow: 0 0 8px rgba(124, 11, 160, 0.5);
  opacity: 1;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* ---------- Snackbar ---------- */

.snackbar-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 48px);
}
.snackbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20, 24, 33, 0.25);
  min-width: 260px;
  max-width: 360px;
  animation: snackbar-in 0.2s ease;
}
.snackbar--out { animation: snackbar-out 0.2s ease forwards; }
.snackbar-icon {
  width: 22px; height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: rgba(255, 255, 255, 0.15);
}
.snackbar--success .snackbar-icon { background: var(--good); }
.snackbar--error .snackbar-icon { background: #E5484D; }
.snackbar-message { flex-grow: 1; font-size: 13.5px; line-height: 1.4; }
.snackbar-close {
  background: none; border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px; line-height: 1;
  padding: 0; cursor: pointer;
}
.snackbar-close:hover { color: #fff; }

@keyframes snackbar-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes snackbar-out { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* ---------- Confirm modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 33, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  padding: 20px;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(20, 24, 33, 0.3);
  transform: scale(0.96);
  transition: transform 0.15s ease;
}
.modal-overlay.open .modal-card { transform: scale(1); }
.modal-title { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.modal-message { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.modal-list { margin: 0 0 20px; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.modal-list li { margin-bottom: 8px; }
.modal-list li:last-child { margin-bottom: 0; }
.modal-list strong { color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn--danger-solid { background: #E5484D; color: #fff; }
.btn--danger-solid:hover { background: #C93A3F; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .dash-sidebar {
    position: fixed;
    left: -260px;
    top: 64px; bottom: 64px;
    height: auto;
    z-index: 30;
    transition: left 0.2s ease;
    box-shadow: 0 0 0 100vmax rgba(0,0,0,0);
  }
  .dash-sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,0.15); }
  .sidebar-toggle { display: block; }
  .dash-main { padding: 16px; padding-bottom: 80px; }
  .dash-footer { padding: 0 16px; }
  .dash-footer-subtitle { display: none; }
  .dash-footer-signature { display: none; }
  .dash-header { padding: 16px 16px 0; }
  .dash-topbar { padding: 0 16px; }
  .sidebar-brand-name { display: none; }
  .snackbar-container { left: 16px; right: 16px; top: auto; bottom: 80px; }
  .snackbar { max-width: none; min-width: 0; }
}
