html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 15px;
  }
}

:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --surface-raised: #ffffff;
  --line: #e5e8ec;
  --line-strong: #c9cfd6;
  --text: #14172a;
  --muted: #6b7280;
  --muted-strong: #454b57;
  --soft: #eef2f6;
  --soft-strong: #dfe5ea;
  --accent: #11679f;
  --accent-hover: #0d4f7c;
  --accent-soft: #e8f4fc;
  --accent-line: #bcdcf0;
  --ink: #14172a;
  --ink-hover: #262a42;
  --success-bg: #e9f8ef;
  --success-text: #1a7042;
  --warn-bg: #fff5df;
  --warn-text: #8a5a0a;
  --danger-bg: #fdedee;
  --danger-text: #b03a3a;
  --info-bg: #eaf2ff;
  --info-text: #315f9d;
  --shadow-sm: 0 1px 2px rgba(20, 23, 42, 0.05), 0 1px 1px rgba(20, 23, 42, 0.04);
  --shadow: 0 10px 24px rgba(20, 23, 42, 0.08), 0 2px 6px rgba(20, 23, 42, 0.05);
  --shadow-lg: 0 20px 45px rgba(20, 23, 42, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --sidebar-bg: #0e1128;
  --sidebar-bg-raised: #171a38;
  --sidebar-text: #c7cbe0;
  --sidebar-text-muted: #7d82a3;
  --sidebar-line: rgba(255, 255, 255, 0.07);
  --sidebar-active-bg: rgba(17, 103, 159, 0.32);
  --sidebar-active-text: #ffffff;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.055);
}

* {
  letter-spacing: 0;
  box-sizing: border-box;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

a:hover {
  color: var(--text);
}

::selection {
  background: var(--accent-line);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.text-muted {
  color: var(--muted) !important;
}

.app-brand,
.side-brand {
  color: var(--text);
  text-decoration: none;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 750;
}

.brand-logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.brand-logo-badge-light {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- Layout shell ---------- */

.erp-layout {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.erp-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-line);
  background: var(--sidebar-bg);
  padding: 1.1rem 0.9rem;
  scrollbar-width: thin;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 50px;
  padding: 0.15rem 0.4rem 1rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--sidebar-line);
  color: #ffffff;
  flex-shrink: 0;
}

.side-brand strong,
.side-brand small {
  display: block;
}

.side-brand strong {
  line-height: 1.15;
  font-size: 0.98rem;
  font-weight: 800;
  color: #ffffff;
}

.side-brand small {
  margin-top: 0.12rem;
  color: var(--sidebar-text-muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.side-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0 0.5rem;
  min-height: 0;
}

.side-section {
  margin: 1.1rem 0 0.4rem;
  padding: 0 0.5rem;
  color: var(--sidebar-text-muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.side-section:first-child {
  margin-top: 0.15rem;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 40px;
  margin: 0.1rem 0;
  padding: 0.5rem 0.55rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 660;
  transition: background 0.12s ease, color 0.12s ease;
}

.side-link:hover,
.side-link:focus-visible {
  background: var(--sidebar-hover-bg);
  color: #ffffff;
  outline: none;
}

.side-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 700;
}

.side-link.active .side-icon {
  color: #ffffff;
}

.side-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: var(--sidebar-text-muted);
}

.side-icon-svg {
  width: 18px;
  height: 18px;
}

.side-link-toggle {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.side-caret {
  margin-left: auto;
  color: var(--sidebar-text-muted);
  font-size: 1rem;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform 0.15s ease, color 0.15s ease;
}

.side-group.open .side-caret {
  color: #ffffff;
  transform: rotate(-90deg);
}

.side-group {
  position: relative;
}

.side-flyout {
  display: none;
  position: fixed;
  top: 3.5rem;
  left: 250px;
  z-index: 1000;
  width: 240px;
  padding: 0.6rem;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: var(--sidebar-bg-raised);
  box-shadow: var(--shadow-lg);
}

.side-flyout.open {
  display: block;
}

.side-flyout-section + .side-flyout-section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--sidebar-line);
}

.side-flyout-label {
  display: block;
  margin: 0 0.4rem 0.25rem;
  color: var(--sidebar-text-muted);
  font-size: 0.64rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.side-flyout-link {
  display: block;
  padding: 0.36rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
}

.side-flyout-link:hover,
.side-flyout-link:focus-visible {
  background: var(--sidebar-hover-bg);
  color: #ffffff;
  outline: none;
}

.erp-content {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(242, 244, 247, 0.92);
  backdrop-filter: blur(14px);
}

.topbar-title {
  font-size: 0.96rem;
  font-weight: 800;
}

.topbar-subtitle {
  margin-top: 0.06rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.navbar .nav-link,
.topbar .nav-link,
.public-header .nav-link {
  color: var(--muted-strong);
  font-weight: 700;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus,
.topbar .nav-link:hover,
.topbar .nav-link:focus,
.public-header .nav-link:hover,
.public-header .nav-link:focus {
  color: var(--text);
}

.btn-link.nav-link {
  text-decoration: none;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 38px;
  max-width: 320px;
  padding: 0.24rem 0.75rem 0.24rem 0.28rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.user-chip:hover,
.user-chip:focus-visible {
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  color: var(--text);
  outline: none;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), #0a3f63);
  font-size: 0.76rem;
  font-weight: 850;
}

.user-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  width: min(1320px, calc(100% - 2.2rem));
  min-height: calc(100vh - 60px);
  margin: 0 auto;
  padding: 1.65rem 0 3rem;
}

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.public-main {
  width: min(100% - 2rem, 920px);
  margin: 0 auto;
  padding: 2rem 0;
}

/* ---------- Page heading ---------- */

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.page-heading > div:first-child {
  min-width: 0;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.1rem);
  font-weight: 830;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.page-heading .btn {
  box-shadow: var(--shadow-sm);
}

.eyebrow,
.metric-label {
  margin-bottom: 0.35rem;
  color: var(--accent-hover);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Cards ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.metric-card,
.work-panel,
.auth-card,
.module-card,
.quick-link,
.table-panel,
.form-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.metric-card {
  position: relative;
  display: block;
  min-height: 116px;
  padding: 1.1rem 1.1rem 1rem;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-line));
}

a.metric-card:hover,
a.metric-card:focus-visible {
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
  color: var(--text);
  outline: none;
  transform: translateY(-2px);
}

.metric-card-alert::before {
  background: linear-gradient(90deg, var(--warn-text), #f2c46a);
}

.metric-card-alert .metric-value {
  color: var(--warn-text);
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 830;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.metric-note {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.work-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  margin-top: 0.9rem;
  padding: 1.1rem;
}

.work-panel h2 {
  margin: 0 0 0.24rem;
  font-size: 1rem;
  font-weight: 820;
}

.work-panel p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
}

.status-list,
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.status-list {
  justify-content: flex-end;
}

.status-list span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 750;
  white-space: nowrap;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.module-card,
.quick-link {
  display: block;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.module-card {
  min-height: 122px;
  padding: 1.1rem;
}

.module-card:hover,
.module-card:focus-visible,
.quick-link:hover,
.quick-link:focus-visible {
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
  color: var(--text);
  outline: none;
  transform: translateY(-2px);
}

.module-card strong,
.module-card span,
.quick-link span,
.quick-link small {
  display: block;
}

.module-card strong {
  font-size: 0.98rem;
  font-weight: 820;
}

.module-card span,
.quick-link small {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.module-card::after {
  content: "A venir";
  display: inline-flex;
  margin-top: 0.9rem;
  padding: 0.24rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-strong);
  background: var(--surface-muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.module-ready::after {
  content: "Disponible";
  color: var(--accent-hover);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.quick-link {
  padding: 1.1rem;
}

.quick-link span {
  font-weight: 820;
}

.auth-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 210px);
  padding: 2rem 1rem;
  overflow: hidden;
  isolation: isolate;
}

.auth-wrap::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(38% 42% at 12% 18%, rgba(17, 103, 159, 0.16), transparent 60%),
    radial-gradient(32% 38% at 88% 82%, rgba(127, 208, 255, 0.16), transparent 60%),
    radial-gradient(60% 60% at 50% 0%, rgba(17, 103, 159, 0.06), transparent 70%);
}

.auth-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(20, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 23, 42, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(60% 60% at 50% 40%, black 30%, transparent 78%);
}

.auth-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  width: min(100%, 940px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--surface);
  border: 1px solid rgba(20, 23, 42, 0.05);
}

.auth-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3.25rem 2.75rem;
  color: #eef4fb;
  overflow: hidden;
  background:
    radial-gradient(120% 140% at 15% 10%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(155deg, #0d4f7c 0%, #11679f 55%, #0e1128 130%);
}

.auth-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.35;
  mask-image: radial-gradient(75% 75% at 30% 20%, black 0%, transparent 70%);
}

.auth-visual::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  right: -80px;
  bottom: -90px;
  border-radius: 999px;
  background: radial-gradient(closest-side, rgba(127, 208, 255, 0.3), transparent 75%);
  filter: blur(2px);
}

.auth-visual > * {
  position: relative;
}

.auth-visual-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 0 14px rgba(127, 208, 255, 0.07), 0 20px 45px rgba(6, 20, 36, 0.35);
}

.auth-visual-badge img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.auth-card {
  position: relative;
  padding: 3.25rem 2.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.auth-eyebrow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.auth-badge-secure {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--success-text);
  background: var(--success-bg);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}

.auth-badge-secure svg {
  width: 12px;
  height: 12px;
}

.auth-title {
  margin-bottom: 0.3rem;
  font-size: 1.6rem;
  font-weight: 830;
  letter-spacing: -0.015em;
}

.auth-subtitle {
  margin-bottom: 1.6rem;
  color: var(--muted);
}

.auth-input {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
  transition: box-shadow 0.15s ease;
}

.auth-input .form-control {
  padding-left: 2.6rem;
  padding-right: 2.6rem;
  height: 46px;
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-input .form-control::-ms-reveal,
.auth-input .form-control::-ms-clear {
  display: none;
}

.auth-input .form-control::-webkit-credentials-auto-fill-button,
.auth-input .form-control::-webkit-textfield-decoration-container,
.auth-input .form-control::-webkit-caps-lock-indicator {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  right: 0;
}

.auth-input .form-control:focus {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.auth-input-icon {
  position: absolute;
  left: 0.9rem;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.15s ease;
}

.auth-input:focus-within .auth-input-icon {
  color: var(--accent);
}

.auth-input-toggle {
  position: absolute;
  z-index: 2;
  right: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}

.auth-input-toggle svg {
  width: 18px;
  height: 18px;
}

.auth-input-toggle:hover {
  color: var(--accent);
  background: var(--soft);
}

.auth-input-toggle.is-active {
  color: var(--accent);
}

.auth-remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.auth-submit {
  position: relative;
  height: 46px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-radius: var(--radius);
  box-shadow: 0 10px 20px rgba(17, 103, 159, 0.22);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.auth-submit:hover {
  box-shadow: 0 14px 26px rgba(17, 103, 159, 0.28);
}

.auth-foot-note {
  margin: 1.4rem 0 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 860px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    padding: 2.25rem 2rem;
  }

  .auth-card {
    padding: 2.25rem 2rem;
  }
}

@media (max-width: 640px) {
  /* Sur telephone, le panneau de presentation est reduit a son identite :
     un simple bandeau avec le logo, pour laisser toute la place au formulaire. */
  .auth-wrap {
    padding: 1rem 0.85rem;
  }

  .auth-visual {
    padding: 1.35rem;
  }

  .auth-visual-badge {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .auth-visual-badge img {
    width: 30px;
    height: 30px;
  }

  .auth-card {
    padding: 1.6rem 1.35rem 1.5rem;
  }

  .auth-title {
    font-size: 1.4rem;
  }
}

/* ---------- Forms ---------- */

.form-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted-strong);
  font-size: 0.86rem;
  font-weight: 750;
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  min-height: 42px;
  border-color: var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background-color: var(--surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea.form-control {
  min-height: 92px;
}

@media (max-width: 768px) {
  /* iOS zoome automatiquement sur un champ dont la police fait moins de 16px,
     ce qui decale toute la page a chaque prise de focus. */
  .form-control,
  .form-select,
  textarea.form-control {
    font-size: 16px;
  }

  /* Cibles tactiles confortables sur les champs et boutons principaux. */
  .form-control,
  .form-select {
    min-height: 46px;
  }

  .btn-primary,
  .btn-outline-dark,
  .btn-danger,
  .btn-secondary {
    min-height: 46px;
  }
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.18rem rgba(17, 103, 159, 0.16);
}

.form-control:hover,
.form-select:hover {
  border-color: var(--line-strong);
}

.form-text {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- Buttons ---------- */

.btn {
  border-radius: var(--radius-sm);
  font-weight: 730;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding-inline: 0.95rem;
  transition: transform 0.13s ease, box-shadow 0.13s ease, border-color 0.13s ease, background 0.13s ease, color 0.13s ease;
}

.btn:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 0.05s;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.55;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-primary,
.btn-outline-dark {
  min-height: 42px;
}

.btn-sm {
  min-height: 34px;
}

.btn-logout {
  min-height: 40px;
  padding: 0.42rem 0.82rem;
  border: 1px solid #f2d0d0;
  color: var(--danger-text);
  background: var(--danger-bg);
  box-shadow: none;
}

.btn-logout:hover,
.btn-logout:focus {
  border-color: #e6abab;
  color: #842b2b;
  background: #ffe6e6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(176, 58, 58, 0.15);
}

.btn-primary {
  border-color: var(--accent);
  background: linear-gradient(180deg, #1573af, var(--accent) 55%, #0f5c8e);
  box-shadow: 0 6px 16px rgba(17, 103, 159, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--accent-hover);
  background: linear-gradient(180deg, #116397, var(--accent-hover) 55%, #0b4269);
  box-shadow: 0 10px 22px rgba(17, 103, 159, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
}

.btn-primary:active {
  box-shadow: 0 3px 8px rgba(17, 103, 159, 0.28), inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.btn-outline-dark {
  border-color: var(--line-strong);
  color: var(--muted-strong);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.btn-outline-dark:hover,
.btn-outline-dark:focus {
  border-color: var(--accent-line);
  color: var(--accent-hover);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(17, 103, 159, 0.12);
}

.form-actions .btn {
  min-width: 104px;
}

.form-actions .btn-primary {
  min-width: 118px;
}

.btn-danger {
  border-color: var(--danger-text);
  background: linear-gradient(180deg, #c04545, var(--danger-text) 55%, #963030);
  box-shadow: 0 6px 14px rgba(176, 58, 58, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.btn-danger:hover,
.btn-danger:focus {
  border-color: #842b2b;
  background: linear-gradient(180deg, #a63b3b, #8f2f2f 55%, #7a2626);
  box-shadow: 0 9px 18px rgba(176, 58, 58, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  border-color: var(--ink);
  background: linear-gradient(180deg, #23273f, var(--ink) 55%, #0d0f1e);
  box-shadow: 0 6px 14px rgba(20, 23, 42, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover,
.btn-secondary:focus {
  border-color: var(--ink-hover);
  background: linear-gradient(180deg, #333854, var(--ink-hover) 55%, #1a1d30);
  box-shadow: 0 9px 18px rgba(20, 23, 42, 0.3);
  transform: translateY(-1px);
}

/* ---------- Filters ---------- */

.filter-bar,
.search-form {
  display: grid;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.filter-bar {
  grid-template-columns: minmax(260px, 1fr) 190px auto;
}

.search-form {
  grid-template-columns: minmax(240px, 1fr) 190px auto;
  margin-bottom: 0;
}

.filter-tabs {
  margin: -0.15rem 0 1rem;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-strong);
  text-decoration: none;
  font-weight: 730;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.filter-tab:hover,
.filter-tab:focus {
  border-color: var(--accent-line);
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.filter-tab.active {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(17, 103, 159, 0.25);
}

/* ---------- Tables ---------- */

.table-panel {
  overflow: hidden;
}

.table-panel .table {
  margin: 0;
  color: var(--text);
}

.table-panel thead th {
  color: #4a5568;
  background: #eef3f8;
  border-bottom: 1px solid var(--line);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.table-panel tbody tr {
  transition: background 0.12s ease;
}

.table-panel tbody tr:hover {
  background: #f5f9fc;
}

.table-panel td,
.table-panel th {
  padding: 0.82rem 0.95rem;
  border-color: var(--line);
  vertical-align: middle;
}

.table-panel td {
  color: var(--muted-strong);
}

.table-panel td.fw-semibold,
.table-panel .fw-semibold {
  color: var(--text);
}

.table-input {
  min-width: 96px;
  max-width: 140px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.panel-header .panel-title {
  margin: 0;
}

.panel-title,
.detail-panel h2,
.form-panel h2 {
  margin: 0 0 0.85rem;
  font-size: 0.96rem;
  font-weight: 820;
  color: var(--accent-hover);
}

.form-panel h2.mt-4 {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.form-panel-md {
  max-width: 920px;
}

.form-section-hint {
  margin: -0.5rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  white-space: nowrap;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 780;
  font-size: 0.82rem;
}

.role-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 34px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 730;
  white-space: nowrap;
}

.role-edit-toggle {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.table-panel .role-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.table-panel .role-form select.form-select {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 190px;
}

.table-panel .role-form .btn,
.table-panel .role-form .link-button {
  flex: 0 0 auto;
}

.table-actions a,
.link-button {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--accent-hover);
  font-size: 0.87rem;
  font-weight: 740;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.table-actions a:hover,
.table-actions a:focus-visible,
.link-button:hover,
.link-button:focus-visible {
  color: var(--accent-hover);
  background: var(--accent-soft);
  text-decoration: none;
  outline: none;
}

.table-actions .text-danger:hover,
.table-actions .text-danger:focus-visible,
.link-button.text-danger:hover,
.link-button.text-danger:focus-visible {
  background: var(--danger-bg);
}

.link-button {
  border: 0;
  background: transparent;
}

/* ---------- Status pills / badges ---------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 25px;
  padding: 0.22rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 760;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.7;
}

.status-active {
  color: var(--success-text);
  background: var(--success-bg);
  border-color: #c9e7d3;
}

.status-muted {
  color: var(--warn-text);
  background: var(--warn-bg);
  border-color: #f2dfbd;
}

/* ---------- Alerts ---------- */

.alert-primary,
.alert-info {
  color: var(--info-text);
  border-color: #c9dcfa;
  background: var(--info-bg);
}

.alert-success {
  color: var(--success-text);
  border-color: #c9e7d3;
  background: var(--success-bg);
}

.alert-warning {
  color: var(--warn-text);
  border-color: #f2dfbd;
  background: var(--warn-bg);
}

.alert-danger {
  color: var(--danger-text);
  border-color: #f1c7c7;
  background: var(--danger-bg);
}

/* ---------- Panels ---------- */

.form-panel,
.detail-panel {
  padding: 1.25rem;
}

.form-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.35rem;
}

.form-grid > .mb-3 {
  margin-bottom: 0 !important;
}

.form-grid-wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.detail-panel dl {
  display: grid;
  grid-template-columns: 155px 1fr;
  gap: 0.65rem 0.9rem;
  margin: 0;
}

.detail-panel dt {
  color: var(--muted);
  font-weight: 750;
}

.detail-panel dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.stack-form {
  display: grid;
  gap: 0.8rem;
}

.alert {
  border-radius: var(--radius);
  border-width: 1px;
}

.table-responsive-soft {
  width: 100%;
  overflow-x: auto;
}

@media (max-width: 1180px) {
  .module-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-height: 800px) and (min-width: 769px) {
  .erp-sidebar {
    padding: 0.6rem 0.6rem;
  }

  .side-brand {
    min-height: 38px;
    padding-bottom: 0.55rem;
    margin-bottom: 0.2rem;
  }

  .side-section {
    margin: 0.4rem 0 0.15rem;
  }

  .side-link {
    min-height: 28px;
    padding: 0.24rem 0.4rem;
    font-size: 0.8rem;
  }
}

/* ---------- Navigation mobile (tiroir) ---------- */

.topbar-burger {
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin-right: 0.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted-strong);
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.topbar-burger svg {
  width: 20px;
  height: 20px;
}

.topbar-burger:hover,
.topbar-burger:focus-visible {
  border-color: var(--accent-line);
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.topbar-heading {
  min-width: 0;
  flex: 1;
}

.topbar-title,
.topbar-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 900px) {
  .erp-layout {
    grid-template-columns: 1fr;
  }

  /* La sidebar sort de l'ecran et revient en tiroir par-dessus le contenu :
     sur mobile la faire defiler avant le contenu obligeait a parcourir toute
     la navigation avant d'atteindre la page. */
  .erp-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1200;
    width: min(84vw, 300px);
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }

  body.sidebar-open .erp-sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(14, 17, 40, 0.45);
    backdrop-filter: blur(2px);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .topbar-burger {
    display: inline-flex;
  }

  /* En tiroir, la sidebar a sa propre zone de defilement : les sous-menus
     peuvent redevenir des blocs empiles plutot que des panneaux flottants. */
  .side-flyout {
    position: static !important;
    width: 100%;
    margin-top: 0.3rem;
    box-shadow: none;
  }
}

@media (max-width: 768px) {
  .topbar {
    gap: 0.6rem;
    padding: 0 0.85rem;
  }

  .topbar-subtitle {
    display: none;
  }

  .user-name {
    display: none;
  }

  .user-chip {
    padding-right: 0.28rem;
  }

  .app-main {
    width: min(100% - 1.6rem, 1180px);
    padding: 1rem 0 2rem;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading .d-flex {
    flex-wrap: wrap;
  }

  /* Sur mobile, les actions de page passent en pleine largeur : des boutons
     colles cote a cote deviennent trop petits pour etre touches correctement. */
  .page-heading .d-flex > .btn,
  .page-heading .d-flex > form,
  .page-heading .d-flex > form > .btn {
    flex: 1 1 auto;
  }

  .metric-grid,
  .quick-grid,
  .module-grid,
  .filter-bar,
  .search-form,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .work-panel {
    display: block;
  }

  .status-list {
    justify-content: flex-start;
    margin-top: 0.85rem;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .btn {
    width: 100%;
  }

  .detail-panel dl {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .detail-panel dd {
    margin-bottom: 0.55rem;
  }

  .auth-card {
    padding: 1.2rem;
  }
}

/* ---------- Tableaux : defilement horizontal maitrise ---------- */

/* Les tableaux metier ont beaucoup de colonnes : plutot que de les ecraser,
   on les fait defiler horizontalement dans leur panneau, sans jamais faire
   defiler la page entiere. */
.table-panel {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-panel > .table {
  min-width: 640px;
}

@media (max-width: 768px) {
  .table-panel td,
  .table-panel th {
    padding: 0.7rem 0.75rem;
  }
}

/* ---------- Empty states (tables) ---------- */

.table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 2.75rem 1.5rem;
  text-align: center;
}

.table-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0.3rem;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
}

.table-empty-icon svg {
  width: 20px;
  height: 20px;
}

.table-empty strong {
  color: var(--muted-strong);
  font-size: 0.92rem;
  font-weight: 750;
}

.table-empty span {
  color: var(--muted);
  font-size: 0.84rem;
}

/* ---------- Status pill: neutral variant (brouillon / annule / archive) ---------- */

.status-neutral {
  color: var(--muted-strong);
  background: var(--soft);
  border-color: var(--line-strong);
}

/* ---------- Semantic text/value helpers (Finance, indicateurs) ---------- */

.text-success {
  color: var(--success-text) !important;
}

.text-warn {
  color: var(--warn-text) !important;
}

.text-info {
  color: var(--info-text) !important;
}

.metric-value-success {
  color: var(--success-text);
}

.metric-value-info {
  color: var(--info-text);
}

/* ---------- Form labels for compact inline forms without floating labels ---------- */

.form-label-sm {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ---------- Status pill: danger variant (rupture / expire / rejete) ---------- */

.status-danger {
  color: var(--danger-text);
  background: var(--danger-bg);
  border-color: #f1c7c7;
}

/* ---------- Filter bar with only a search field + submit (no select) ---------- */

.filter-bar:has(> :nth-child(2):last-child) {
  grid-template-columns: minmax(260px, 1fr) auto;
}

/* =========================================================================
   Lot design : Dashboard, Tresorerie, Documents, Achats internes,
   Notes de frais, Administration, Profil, Initialisation.
   Bloc strictement additif : aucune regle existante n'est modifiee.
   ========================================================================= */

/* ---------- Grilles d'indicateurs a 2 ou 3 colonnes ----------
   .metric-grid vaut 4 colonnes : une page qui n'affiche que 2 ou 3 indicateurs
   laissait une colonne vide et des cartes demesurement larges. */

.metric-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1180px) {
  .metric-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Valeurs d'indicateurs : couleurs semantiques ---------- */

.metric-value-warn {
  color: var(--warn-text);
}

.metric-value-muted {
  color: var(--muted-strong);
}

/* ---------- Pastille d'etat : variante information (en cours, par defaut) ---------- */

.status-info {
  color: var(--info-text);
  background: var(--info-bg);
  border-color: #c9dcfa;
}

/* ---------- Raccourcis actionnables du bloc de synthese (Dashboard) ----------
   Les elements de .status-list etaient de simples <span> decoratifs ; ils
   deviennent des liens vers les ecrans concernes, avec le compteur associe. */

.status-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--muted-strong);
  font-size: 0.87rem;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.status-link:hover,
.status-link:focus-visible {
  border-color: var(--accent-line);
  color: var(--accent-hover);
  background: var(--accent-soft);
  outline: none;
  box-shadow: var(--shadow-sm);
}

/* Selecteur a deux classes : le compteur est un <span> place dans .status-list,
   dont la regle .status-list span (0,1,1) l'emporterait sinon sur une classe
   simple et lui donnerait l'aspect d'une etiquette encadree. */
.status-link .status-link-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 0.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--soft-strong);
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}

.status-link-warn {
  border-color: #f2dfbd;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.status-link-warn .status-link-count {
  background: rgba(138, 90, 10, 0.16);
  color: var(--warn-text);
}

.status-link-warn:hover,
.status-link-warn:focus-visible {
  border-color: #e6c98f;
  background: #fdedcf;
  color: var(--warn-text);
}

/* ---------- Titres de section hors panneau (Dashboard) ---------- */

.dash-section-title {
  margin: 1.5rem 0 0.15rem;
  color: var(--accent-hover);
  font-size: 0.96rem;
  font-weight: 820;
}

.dash-section-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------- Tableaux denses : largeur minimale plus confortable ----------
   .table-panel > .table impose 640px ; au-dela de 7 colonnes ce plancher
   ecrase les libelles. Cette variante s'applique aux tableaux les plus larges. */

.table-panel-wide > .table {
  min-width: 900px;
}

/* ---------- Barre de recherche a quatre controles ---------- */

.search-form-wide {
  grid-template-columns: minmax(200px, 1fr) 170px 110px auto;
}

@media (max-width: 1180px) {
  .search-form-wide {
    grid-template-columns: minmax(170px, 1fr) 150px 100px auto;
  }
}

/* ---------- Sous-groupe de formulaire (champs conditionnels) ----------
   Isole visuellement les champs qui ne concernent qu'une partie des cas,
   pour qu'ils ne soient plus lus comme obligatoires. */

.form-subgroup {
  padding: 0.9rem 1rem 0.35rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.form-subgroup-title {
  margin: 0 0 0.2rem;
  color: var(--muted-strong);
  font-size: 0.88rem;
  font-weight: 800;
}

.form-subgroup-hint {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.5;
}

/* ---------- Colonnes du tableau des utilisateurs (ex-style inline) ---------- */

.user-table-col-user {
  width: 26%;
}

.user-table-col-role {
  width: 20%;
}

.user-table-col-status {
  width: 16%;
}

.user-table-col-actions {
  width: 38%;
}

.user-table .table-actions {
  flex-wrap: wrap;
  row-gap: 0.1rem;
}

.user-status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.temp-password-box {
  display: inline-block;
  margin: 0.35rem 0;
  padding: 0.5rem 0.85rem;
  background: #fff;
  border: 1px dashed rgba(20, 23, 42, 0.35);
  border-radius: 8px;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  user-select: all;
}

/* ---------- Divers utilitaires remplacant des style= inline ---------- */

.setup-panel {
  width: 100%;
  max-width: 460px;
}

.icon-flush {
  margin-bottom: 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* ---------- Mobile : densite, lisibilite et cibles tactiles ---------- */

@media (max-width: 768px) {
  /* Une seule colonne d'indicateurs produisait un empilement tres long avant
     le premier contenu utile : deux colonnes restent lisibles des 320px. */
  .metric-grid,
  .metric-grid-2,
  .metric-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .metric-card {
    min-height: 0;
    padding: 0.85rem 0.8rem 0.8rem;
  }

  .metric-value {
    font-size: 1.3rem;
    overflow-wrap: anywhere;
  }

  .metric-note {
    margin-top: 0.45rem;
  }

  /* Idem pour les dix tuiles de modules : en une colonne la page faisait
     plusieurs ecrans de defilement pour un simple menu. */
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .module-card {
    min-height: 0;
    padding: 0.9rem 0.85rem;
  }

  .module-card strong {
    font-size: 0.95rem;
  }

  .module-card span {
    display: none;
  }

  .module-ready::after {
    display: none;
  }

  /* Texte courant ramene au-dessus du seuil de lisibilite (13px). */
  .metric-note,
  .form-text,
  .form-section-hint,
  .form-subgroup-hint,
  .table-empty span,
  .dash-section-note {
    font-size: 0.93rem;
  }

  .status-pill,
  .role-badge,
  .status-list span,
  .status-link {
    font-size: 0.93rem;
  }

  /* Micro-libelles en capitales : releves sans casser les gabarits. */
  .eyebrow,
  .metric-label,
  .table-panel thead th {
    font-size: 0.86rem;
  }

  /* Cibles tactiles : les actions de tableau sont des liens tres compacts. */
  .table-actions a,
  .link-button,
  .role-edit-toggle {
    min-height: 40px;
    padding: 0.5rem 0.65rem;
  }

  .table-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* Edition du role en ligne : le select et ses deux boutons ne tiennent pas
     sur une seule ligne dans la largeur d'une cellule. */
  .role-cell {
    flex-wrap: wrap;
  }

  .table-panel .role-form {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .table-panel .role-form select.form-select {
    flex: 1 1 100%;
    max-width: none;
  }

  .table-panel .role-form .btn,
  .table-panel .role-form .link-button {
    flex: 1 1 auto;
    min-width: 110px;
  }

  /* Raccourcis du bloc de synthese : pleine largeur repartie. */
  .status-list .status-link {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 44px;
    white-space: normal;
    text-align: center;
  }

  .status-link .status-link-count {
    font-size: 0.9rem;
  }

  .search-form-wide {
    grid-template-columns: 1fr;
  }

  .btn-block-sm {
    width: 100%;
  }

  .form-subgroup {
    padding: 0.85rem 0.85rem 0.3rem;
  }
}

/* =========================================================================
   Lot design : Referentiel (Clients, Fournisseurs), Produits, Stocks,
   BC fournisseur.
   Bloc strictement additif : aucune regle existante n'est modifiee.
   ========================================================================= */

/* ---------- Cellules de tableau : chiffres, dates, liens ----------
   Les colonnes de montants et de quantites etaient alignees a gauche avec une
   police proportionnelle : deux nombres du meme ordre de grandeur n'etaient
   pas comparables d'un coup d'oeil. */

.cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-nowrap {
  white-space: nowrap;
}

/* Email, telephone et fiches liees deviennent cliquables (appel ou mail direct
   depuis un mobile) sans teinter en bleu toute la grille. */
.cell-link {
  color: var(--muted-strong);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.cell-link:hover,
.cell-link:focus-visible {
  color: var(--accent-hover);
  text-decoration: underline;
}

.table-panel td.fw-semibold .cell-link,
.page-heading .cell-link {
  color: var(--text);
}

/* Precision secondaire sous une valeur de cellule (numeros de lots recus...). */
.cell-note {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

/* ---------- Formulaire compact dans une cellule de tableau ----------
   La reception de lot d'un BC fournisseur utilisait une grille Bootstrap
   .row/.col a l'interieur d'une cellule : les trois champs se partageaient une
   largeur residuelle et devenaient inutilisables des que le tableau se
   resserrait. Ils gardent desormais une largeur minimale et passent a la ligne
   plutot que d'etre ecrases. */

.cell-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 300px;
}

.cell-form-field {
  flex: 1 1 108px;
  min-width: 108px;
}

.cell-form-field-lg {
  flex: 1 1 150px;
  min-width: 150px;
}

.cell-form .form-control {
  min-width: 0;
}

.cell-form-action {
  flex: 0 0 auto;
  align-self: flex-end;
}

.cell-form-action .btn {
  min-height: 42px;
}

/* ---------- Lignes signalees : stock bas, rupture, peremption ----------
   Le lisere est porte par la premiere colonne : il reste visible meme lorsque
   le tableau defile horizontalement sur mobile. */

.table-panel tbody tr.row-warn > td:first-child {
  box-shadow: inset 3px 0 0 var(--warn-text);
}

.table-panel tbody tr.row-danger > td:first-child {
  box-shadow: inset 3px 0 0 var(--danger-text);
}

/* ---------- Case a cocher confortable dans un formulaire empile ---------- */

.form-check-touch {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.form-check-touch .form-check-input {
  width: 1.15em;
  height: 1.15em;
  margin-top: 0.16em;
}

.form-check-touch .form-check-label {
  display: inline-block;
  padding: 0.3rem 0;
  cursor: pointer;
}

/* ---------- Masquage sur tres petit ecran ----------
   Reserve aux colonnes secondaires (prix converti, date de reception, quantite
   initiale) : la donnee reste accessible sur la fiche de detail. Jamais une
   information critique. */

@media (max-width: 640px) {
  .hide-sm {
    display: none !important;
  }
}

/* ---------- Lisibilite et cibles tactiles sur mobile ---------- */

@media (max-width: 768px) {
  /* Aucun texte sous 13px : la racine vaut 14px sur mobile, 0.93rem = 13px. */
  .table-panel .status-pill,
  .cell-note {
    font-size: 0.93rem;
  }

  /* Les liens d'action d'un tableau mesuraient environ 28px de haut, sous le
     minimum confortable au doigt. */
  .table-actions a,
  .table-actions .link-button,
  .table-panel .link-button {
    min-height: 40px;
    padding-inline: 0.6rem;
    font-size: 0.93rem;
  }

  /* Formulaire en cellule : un champ par ligne, bouton pleine largeur. */
  .cell-form {
    min-width: 240px;
  }

  .cell-form-field,
  .cell-form-field-lg {
    flex: 1 1 100%;
    min-width: 0;
  }

  .cell-form-action {
    width: 100%;
  }

  .cell-form-action .btn {
    width: 100%;
    min-height: 46px;
  }
}

/* =========================================================================
   Lot design : Ventes (Commandes, Proformas, Factures, Colisage) et
   Achats directs.
   Bloc strictement additif : aucune regle existante n'est modifiee.
   Les utilitaires deja presents plus haut (.cell-form, .cell-form-field,
   .cell-form-action, .cell-num, .hide-sm, .status-info) sont reutilises.
   ========================================================================= */

/* ---------- Actions de page : deux par ligne sur mobile ----------
   Une fiche proforma ou facture aligne jusqu'a six actions. Etirees a parts
   egales elles devenaient six boutons illisibles de quelques dizaines de
   pixels ; elles se repartissent desormais sur deux colonnes. */

.page-actions {
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .page-actions > .btn,
  .page-actions > form {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: calc(50% - 0.5rem);
  }

  .page-actions > form {
    display: flex;
  }

  .page-actions > form > .btn {
    width: 100%;
  }
}

/* ---------- Sous-titre d'un en-tete de panneau ----------
   Remplace les consignes repetees a chaque ligne d'un tableau (mode d'emploi
   d'un formulaire en cellule) : l'explication n'apparait plus qu'une fois. */

.panel-subtitle {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.87rem;
  line-height: 1.45;
  max-width: 92ch;
}

/* L'en-tete d'un panneau qui defile horizontalement reste a gauche : sinon le
   titre et sa consigne sortent de l'ecran des que l'on fait defiler le tableau. */
.table-panel > .panel-header {
  position: sticky;
  left: 0;
}

/* ---------- Premiere colonne figee sur les tableaux larges ----------
   Sur mobile un tableau de huit a treize colonnes defile horizontalement dans
   son panneau : sans ancrage on ne sait plus quelle ligne on lit. L'identifiant
   (numero, produit, reference colis) reste donc visible. */

.table-sticky-first > thead > tr > th:first-child,
.table-sticky-first > tbody > tr > td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}

.table-sticky-first > thead > tr > th:first-child {
  z-index: 3;
  background: #eef3f8;
}

.table-panel .table-sticky-first > tbody > tr:hover > td:first-child {
  background: #f5f9fc;
}

/* ---------- Cellules de saisie en ligne ----------
   Une cellule qui contient un champ ne doit pas etre comprimee par les
   colonnes de texte voisines. */

.cell-input-col {
  min-width: 124px;
}

/* Champ court d'un formulaire en cellule (nombre de mois, compteur). */
.cell-form-field-sm {
  flex: 0 1 104px;
  min-width: 96px;
}

/* Valeur calculee affichee au milieu d'un formulaire en cellule. */
.cell-form-value {
  display: block;
  min-height: 31px;
  padding-top: 0.3rem;
  color: var(--muted-strong);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .cell-form-field-sm {
    flex: 1 1 100%;
    min-width: 0;
  }

  .cell-form-value {
    padding-top: 0;
  }
}

/* ---------- Case a cocher portant le libelle de la ligne ----------
   Les cases d'une liste de colisage n'avaient aucun libelle associe : la zone
   cliquable se limitait au carre de 16px et le lecteur d'ecran annoncait une
   case anonyme. Le nom du produit devient le libelle. */

.check-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 40px;
  margin: 0;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}

.check-cell .form-check-input {
  flex: 0 0 auto;
  width: 1.2em;
  height: 1.2em;
  margin: 0;
}

/* ---------- Montants : hierarchie et alignement ----------
   Un achat cumule un total USD et un total EUR : la devise passe au second
   plan pour que les deux montants restent comparables. */

.amount-stack {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.amount-stack-end {
  align-items: flex-end;
}

.amount-line {
  display: inline-flex;
  align-items: baseline;
  gap: 0.32rem;
  white-space: nowrap;
}

.amount-value {
  color: var(--text);
  font-weight: 790;
  font-variant-numeric: tabular-nums;
}

.amount-currency {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.num-cell {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
  .amount-currency {
    font-size: 0.87rem;
  }

  .panel-subtitle {
    font-size: 0.93rem;
  }
}

/* ---------- Grille de formulaire a l'interieur d'un panneau de detail ----------
   Les colonnes Bootstrap col-md-* reagissent a la largeur de la fenetre, pas a
   celle du panneau : dans un .detail-panel de demi-largeur, trois colonnes se
   partageaient environ cent pixels chacune entre 769px et 1180px. Cette grille
   repasse sur une seule colonne des que le panneau devient etroit. */

.panel-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.panel-form-grid-wide {
  grid-column: 1 / -1;
}

@media (max-width: 1180px) {
  .panel-form-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Formulaire cible d'un champ deporte (attribut form=) ----------
   Les lignes editables utilisent un <form> vide comme cible : vide, il occupait
   quand meme un emplacement dans la cellule d'actions en flex. */

.table-actions form:empty {
  display: none;
}

/* ============================================================
   Composeur de palettes (listes de colisage)
   ------------------------------------------------------------
   Remplace le tableau a defilement horizontal : un bloc par
   produit facture, des cartes-palette empilees, ajout par « + ».
   ============================================================ */

.palette-composer {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

/* --- Bloc produit --- */

.palette-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.palette-group.is-excluded {
  opacity: 0.55;
}

.palette-group.is-over {
  border-color: var(--warn-text);
  box-shadow: 0 0 0 1px var(--warn-text) inset, var(--shadow-sm);
}

.palette-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.9rem 1.1rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
  border-bottom: 1px solid var(--line);
}

.palette-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--text);
  cursor: pointer;
}

.palette-group-toggle .form-check-input {
  width: 1.2em;
  height: 1.2em;
  margin: 0;
  flex: 0 0 auto;
}

.palette-group-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

/* Jauge de progression quantite expediee / facturee */
.palette-gauge {
  --pct: 0%;
  position: relative;
  width: 120px;
  height: 6px;
  border-radius: 999px;
  background: var(--soft-strong);
  overflow: hidden;
}

.palette-gauge::before {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--pct);
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s ease;
}

.palette-group.is-complete .palette-gauge::before {
  background: var(--success-text);
}

.palette-group.is-over .palette-gauge::before {
  background: var(--warn-text);
}

.palette-count-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.palette-progress-text {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.palette-group.is-complete .palette-progress-text {
  color: var(--success-text);
}

.palette-group.is-over .palette-progress-text {
  color: var(--warn-text);
}

/* --- Valeurs par defaut du produit (dimensions / douane) --- */

.palette-defaults {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem 0.9rem;
  padding: 0.85rem 1.1rem;
  background: var(--surface-muted);
  border-bottom: 1px dashed var(--line-strong);
}

.palette-defaults .form-label {
  margin-bottom: 0.2rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.palette-defaults .form-control {
  height: 38px;
}

.palette-defaults-hint {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Liste des cartes-palette --- */

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1rem 1.1rem;
}

.palette-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr) auto;
  align-items: end;
  gap: 0.65rem 0.8rem;
  padding: 0.85rem 0.9rem 0.85rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.palette-card:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
}

.palette-card.is-removing {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
}

.palette-card-index {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.palette-card .form-label {
  margin-bottom: 0.25rem;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.palette-card .form-control {
  height: 40px;
}

.palette-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.palette-card-actions {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  align-self: center;
}

.palette-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.palette-icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.palette-icon-btn.is-danger:hover {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.palette-icon-btn svg {
  width: 17px;
  height: 17px;
}

/* Repli « + détails » : lot, code douanier, pays, notes */
.palette-card-extra {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem 0.8rem;
  margin-top: 0.15rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--line-strong);
}

.palette-card-extra[hidden] {
  display: none;
}

.palette-disclosure {
  grid-column: 1 / -1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.1rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 750;
  font-size: 0.82rem;
  cursor: pointer;
}

.palette-disclosure svg {
  width: 14px;
  height: 14px;
  transition: transform 0.18s ease;
}

.palette-disclosure[aria-expanded="true"] svg {
  transform: rotate(90deg);
}

/* --- Pied de bloc : bouton d'ajout --- */

.palette-group-foot {
  padding: 0.15rem 1.1rem 1.1rem;
}

.palette-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border: 1.5px dashed var(--accent-line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.palette-add-btn:hover {
  background: #dcecf8;
  border-color: var(--accent);
}

.palette-add-btn svg {
  width: 16px;
  height: 16px;
}

.palette-empty {
  padding: 0.9rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

/* --- Responsive --- */

@media (max-width: 900px) {
  .palette-defaults {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .palette-card {
    grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr);
  }

  .palette-card .palette-field-dimensions {
    grid-column: 2 / -1;
  }

  .palette-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .palette-card-extra {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .palette-card {
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: start;
  }

  .palette-card .palette-field {
    grid-column: 2 / -1;
  }

  .palette-card .palette-card-index {
    align-self: start;
    grid-row: 1;
    min-height: 40px;
    height: 40px;
  }

  .palette-card-actions {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }

  .palette-defaults,
  .palette-card-extra {
    grid-template-columns: 1fr;
  }

  .palette-group-meta {
    width: 100%;
    margin-left: 0;
  }
}

/* ============================================================
   Jalons de commande (Commande / PF / Facture / Colisé / Expédié / Livré)
   ------------------------------------------------------------
   Bandeau complet sur les fiches Commande/PF/Facture/Colisage,
   version compacte (pastilles seules) sur la liste des commandes.
   ============================================================ */

.milestones-track {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 0.9rem 0.5rem;
  flex-wrap: wrap;
}

.milestone-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 74px;
  text-align: center;
}

.milestone-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: #fff;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.milestone-dot svg {
  width: 15px;
  height: 15px;
}

.milestone-step.is-pending .milestone-dot {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.milestone-step.is-partial .milestone-dot {
  border-color: var(--warn-text);
  background: var(--warn-text);
  box-shadow: 0 0 0 3px var(--warn-bg);
}

.milestone-step.is-done .milestone-dot {
  border-color: var(--success-text);
  background: var(--success-text);
}

.milestone-label {
  font-size: 0.78rem;
  font-weight: 750;
  color: var(--muted);
}

.milestone-step.is-done .milestone-label {
  color: var(--success-text);
}

.milestone-step.is-partial .milestone-label {
  color: var(--warn-text);
}

.milestone-detail {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.milestone-connector {
  flex: 1 1 24px;
  min-width: 16px;
  height: 2px;
  margin-top: 13px;
  background: var(--line-strong);
  align-self: flex-start;
}

.milestone-connector.is-done {
  background: var(--success-text);
}

@media (max-width: 640px) {
  .milestones-track {
    gap: 0.5rem 0;
  }

  .milestone-step {
    min-width: 62px;
  }

  .milestone-connector {
    display: none;
  }
}

/* --- Version compacte (listes) --- */

.milestones-compact {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.milestone-dot-sm {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--line-strong);
}

.milestone-dot-sm.is-partial {
  background: var(--warn-text);
}

.milestone-dot-sm.is-done {
  background: var(--success-text);
}

/* ---------- Suivi expedition (colisage) : une carte par conteneur ----------
   Les cartes se replient (flex-wrap) : aucune largeur minimale, donc plus de
   defilement horizontal et les actions (Annuler / Supprimer) restent visibles. */

.tracking-list {
  display: flex;
  flex-direction: column;
}

.tracking-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.5rem;
  padding: 0.95rem 1.25rem;
  border-top: 1px solid var(--line);
}

.tracking-main {
  flex: 1 1 220px;
  min-width: 0;
}

.tracking-ref {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
}

.tracking-ref strong {
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.tracking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.5rem;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.tracking-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
}

.tracking-date-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
}

.tracking-date-field span {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.tracking-date-field .form-control {
  width: 9.5rem;
}

.tracking-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  min-height: 34px;
}

.tracking-add-form {
  margin: 0;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 768px) {
  .tracking-card {
    padding: 0.9rem 1rem;
  }

  .tracking-dates,
  .tracking-date-field,
  .tracking-date-field .form-control {
    width: 100%;
  }

  .tracking-dates .btn {
    width: 100%;
  }
}

/* ---------- Administration d'une commande (renumeroter / supprimer) ---------- */

.order-admin-block {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.order-admin-block h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 800;
}

.order-admin-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.order-admin-inline > div {
  flex: 1 1 240px;
  max-width: 360px;
}

.order-admin-danger h3 {
  color: var(--danger-text);
}

.order-admin-notes {
  margin: 0 0 0.9rem;
  padding-left: 1.1rem;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

/* Date de document (PF / facture) modifiable par l'administrateur */
.doc-date-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line-strong);
}

.doc-date-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.doc-date-form .form-control {
  width: 10rem;
}

/* --- Double authentification (MFA) --- */
.mfa-wrap {
  width: min(100%, 760px);
  margin: 0 auto;
}

.mfa-steps {
  margin: 0 0 1.25rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.mfa-setup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}

.mfa-qr {
  padding: 0.6rem;
  background: #fff;
  border: 1px solid rgba(20, 23, 42, 0.12);
  border-radius: 12px;
  line-height: 0;
}

.mfa-key {
  display: block;
  padding: 0.55rem 0.75rem;
  background: rgba(20, 23, 42, 0.05);
  border-radius: 8px;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  word-break: break-all;
}

.mfa-codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.mfa-codes li {
  padding: 0.55rem 0.75rem;
  background: rgba(20, 23, 42, 0.05);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.98rem;
  text-align: center;
  user-select: all;
}

@media (max-width: 640px) {
  .mfa-setup {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .mfa-setup-form {
    width: 100%;
  }
}

/* --- Tresorerie : banques connectees (Enable Banking) --- */
.bank-overview {
  margin-bottom: 1.25rem;
}

.bank-overview .panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.bank-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.bank-total strong {
  font-size: 1.35rem;
}

.bank-balance-card {
  color: inherit;
  text-decoration: none;
}

.bank-connect-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  max-width: 560px;
}

.bank-connect-row .form-select {
  flex: 1 1 260px;
}

.bank-filter-form {
  flex-wrap: wrap;
}

.bank-category-form .form-select {
  min-width: 11rem;
}

.bank-tx-table td {
  vertical-align: middle;
}

.bank-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.9rem;
}

.bank-callback {
  width: min(100%, 560px);
  text-align: center;
}

.bank-callback .alert {
  text-align: left;
}

.bank-hero {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.9rem;
}

.bank-hero strong {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.finance-section-title {
  margin: 1.4rem 0 0.7rem;
  font-size: 1rem;
  font-weight: 750;
  color: var(--muted-strong, #3c4257);
}

.bank-connect-panel {
  padding: 1rem 1.1rem 1.2rem;
  border-top: 1px solid rgba(20, 23, 42, 0.08);
}

.bank-connect-panel h3 {
  font-size: 0.95rem;
  font-weight: 750;
  margin: 0 0 0.3rem;
}

/* --- Montants bancaires : vert = recu, rouge = sorti, gris = entre nos comptes --- */
.amount-in {
  color: var(--success-text);
}

.amount-out {
  color: var(--danger-text);
}

.amount-internal {
  color: var(--muted);
}

/* --- Graphiques de tresorerie --- */
.chart-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0 0.9rem;
}

.chart-filter {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
  background: var(--surface);
}

.chart-filter:hover,
.chart-filter:focus-visible {
  border-color: var(--line-strong);
}

.chart-filter.is-active {
  color: #ffffff;
  background: #11679f;
  border-color: #11679f;
}

.chart-panel {
  margin-bottom: 1rem;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.chart-grid .chart-panel {
  margin-bottom: 0;
}

.chart,
.chart-host {
  position: relative;
}

.chart {
  width: 100%;
  min-height: 60px;
}

.chart:focus-visible {
  outline: 2px solid #11679f;
  outline-offset: 4px;
  border-radius: 6px;
}

.chart svg {
  display: block;
  overflow: visible;
}

.chart-axis {
  font-size: 11px;
  fill: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chart-end-label,
.chart-cat-label {
  font-size: 12px;
  fill: var(--text);
}

.chart-value {
  font-size: 12px;
  fill: var(--muted-strong);
  font-variant-numeric: tabular-nums;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted-strong);
}

.chart-key-line,
.chart-key-rect {
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.chart-key-line {
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

.chart-key-rect {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  padding: 0.5rem 0.65rem;
  background: #ffffff;
  border: 1px solid rgba(20, 23, 42, 0.12);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 23, 42, 0.12);
  font-size: 0.8rem;
  pointer-events: none;
}

.chart-tooltip-title {
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.chart-tooltip-row strong {
  font-variant-numeric: tabular-nums;
}

.chart-tooltip-row span {
  color: var(--muted-strong);
}

.chart-table {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.chart-table summary {
  cursor: pointer;
  color: var(--muted-strong);
}

.chart-table table {
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.chart-table-scroll {
  max-height: 280px;
  overflow: auto;
}

.projection-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--muted-strong);
}

.legend-rect {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: middle;
}

.legend-solde,
.projection-seg-solde {
  background: #2a78d6;
}

.legend-attendu,
.projection-seg-attendu {
  background: #86b6ef;
}

.projection-bar {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-top: 0.5rem;
}

.projection-seg {
  display: block;
  min-width: 4px;
}

.projection-seg:first-child {
  border-radius: 4px 0 0 4px;
}

.projection-seg:last-child {
  border-radius: 0 4px 4px 0;
}

/* --- Releves bancaires --- */
.statement-form {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
}

.statement-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.statement-balance-row td {
  font-weight: 700;
  background: var(--surface-muted);
}

@media (max-width: 900px) {
  .chart-grid,
  .statement-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Soldes bancaires, dernieres operations : sur telephone, le montant reste visible
   (compte et categorie masques ; le detail complet est dans Operations bancaires). */
@media (max-width: 640px) {
  .bank-recent-table th:nth-child(2),
  .bank-recent-table td:nth-child(2),
  .bank-recent-table th:nth-child(4),
  .bank-recent-table td:nth-child(4) {
    display: none;
  }

  /* Exception a la largeur minimale des tableaux denses : ici, trois colonnes tiennent a l'ecran. */
  .table-panel > .bank-recent-table,
  .table-panel-wide > .bank-recent-table {
    min-width: 0;
  }

  .bank-recent-table td:nth-child(3) {
    overflow-wrap: anywhere;
  }
}

/* --- Prevision de tresorerie --- */
.chart-key-dashed,
.chart-key-ring {
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
}

.chart-key-dashed {
  width: 14px;
  height: 2px;
  background: repeating-linear-gradient(90deg, #2a78d6 0 5px, transparent 5px 8px);
}

.chart-key-ring {
  width: 9px;
  height: 9px;
  border: 2px solid #2a78d6;
  border-radius: 999px;
  background: #ffffff;
}

.forecast-scenario {
  margin-bottom: 1rem;
}

.forecast-horizons {
  margin-top: 0.5rem;
  margin-bottom: 0.6rem;
}

.forecast-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.4rem;
  font-size: 0.9rem;
}

.forecast-options .form-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding-left: 0;
}

.forecast-options .form-check-input {
  margin: 0;
}

.forecast-delay {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted-strong);
}

.forecast-delay .form-select {
  width: auto;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.forecast-events-scroll {
  max-height: 420px;
  overflow: auto;
}

.forecast-check-col {
  width: 2.5rem;
}

.forecast-row-ignored td {
  color: var(--muted);
}

.forecast-row-ignored .amount-in,
.forecast-row-ignored .amount-out {
  color: var(--muted);
}

.forecast-date {
  max-width: 11rem;
}

.forecast-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.forecast-recurring-table .table-actions form {
  display: inline;
}

@media (max-width: 1100px) {
  .forecast-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .forecast-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .forecast-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.forecast-grid .table-panel > .table {
  min-width: 0;
}

.bank-recurring-badge {
  display: inline-flex;
  margin-top: 0.2rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  color: var(--info-text);
  background: var(--info-bg);
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.bank-recurring-badge:hover,
.bank-recurring-badge:focus-visible {
  text-decoration: underline;
}

.bank-recurring-form {
  display: inline;
}

.bank-recurring-form .link-button {
  margin-top: 0.1rem;
  padding: 0.05rem 0.35rem;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--muted-strong);
}

/* Mois par mois sur telephone : le solde de fin reste visible (le debut = fin du mois precedent). */
@media (max-width: 640px) {
  .forecast-month-table th:nth-child(2),
  .forecast-month-table td:nth-child(2) {
    display: none;
  }
}

/* Legende du graphique de solde : comptes a cocher. */
.chart-legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  cursor: pointer;
}

.chart-legend-toggle .form-check-input {
  margin: 0;
  cursor: pointer;
}

.chart-legend-toggle .chart-key-line {
  margin-right: 0;
}

/* --- Fiche client : interrupteur International / France --- */
.client-scope {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.1rem;
  margin-bottom: 1.25rem;
}

.client-scope-toggle {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted, #f1f3f6);
  box-shadow: inset 0 1px 2px rgba(20, 23, 42, 0.06);
  isolation: isolate;
}

.client-scope-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.client-scope-toggle label {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 9.5rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 750;
  cursor: pointer;
  user-select: none;
  transition: color 0.25s ease;
}

.client-scope-toggle label svg {
  width: 17px;
  height: 17px;
}

.client-scope-slider {
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: linear-gradient(135deg, #0f2a44, #11679f);
  box-shadow: 0 4px 12px rgba(17, 103, 159, 0.35);
  transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1), background 0.35s ease;
}

#client-scope-intl:checked + label,
#client-scope-fr:checked + label {
  color: #ffffff;
}

#client-scope-fr:checked ~ .client-scope-slider {
  transform: translateX(100%);
  background: linear-gradient(135deg, #002395 0%, #1d4fbf 55%, #c8102e 140%);
}

.client-scope-toggle input:focus-visible + label {
  outline: 2px solid #11679f;
  outline-offset: 2px;
}

.client-scope-flag {
  display: inline-flex;
  overflow: hidden;
  width: 20px;
  height: 14px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.client-scope-flag i {
  flex: 1;
}

.client-scope-flag i:nth-child(1) { background: #002395; }
.client-scope-flag i:nth-child(2) { background: #ffffff; }
.client-scope-flag i:nth-child(3) { background: #ed2939; }

.client-scope-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.client-ids {
  margin: 0 0 1rem;
  padding: 1rem 1.1rem 0.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-muted, #f8f9fb);
  animation: client-ids-in 0.3s ease;
}

.client-ids legend {
  float: none;
  width: auto;
  margin: 0 0 0.35rem;
  padding: 0;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--accent-hover);
}

@keyframes client-ids-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* Affichage selon le choix (sans JavaScript) */
.client-scope-hint-fr,
form:has(#client-scope-fr:checked) .client-scope-hint-intl,
form:has(#client-scope-fr:checked) .client-ids-intl,
.client-ids-fr {
  display: none;
}

form:has(#client-scope-fr:checked) .client-scope-hint-fr {
  display: block;
}

form:has(#client-scope-fr:checked) .client-ids-fr {
  display: block;
}

@media (max-width: 640px) {
  .client-scope-toggle {
    width: 100%;
  }

  .client-scope-toggle label {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .client-scope-slider,
  .client-ids {
    transition: none;
    animation: none;
  }
}

.client-badge-fr {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
