/* Elunis ONE — couche visuelle commune (2026).
   Chargée après les thèmes, limitée à l'ERP connecté (.erp-shell) : connexion, portails et
   pages publiques restent inchangés. Aucune couleur fixe : tout dérive des variables du thème
   actif (--blue, --surface, --line, --elunis-accent…), clairs comme sombres. */

/* Jetons de conception : globaux (le menu du compte sert aussi hors de l'ERP). */
html {
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --ring: 0 0 0 3px color-mix(in srgb, var(--blue) 26%, transparent);
  --lift: 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent), 0 8px 24px -12px color-mix(in srgb, var(--ink) 22%, transparent);
  --lift-strong: 0 2px 4px color-mix(in srgb, var(--ink) 6%, transparent), 0 18px 40px -18px color-mix(in srgb, var(--ink) 34%, transparent);
  --accent: var(--elunis-accent, var(--blue-hover));
  --brand-gradient: linear-gradient(135deg, var(--elunis-primary, var(--blue)) 0%, var(--elunis-secondary, var(--blue-hover)) 58%, var(--accent) 130%);
  /* Boutons : --blue est clair dans les thèmes sombres, où --button-ink devient foncé. */
  --button-gradient: linear-gradient(135deg, var(--blue) 0%, var(--blue-hover) 100%);
  --tint: color-mix(in srgb, var(--blue) 7%, var(--surface));
}
.erp-shell {
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 420px at 78% -140px, color-mix(in srgb, var(--accent) 11%, transparent), transparent 70%),
    radial-gradient(900px 380px at 8% -120px, color-mix(in srgb, var(--blue) 8%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
.erp-shell h1, .erp-shell h2, .erp-shell h3 { letter-spacing: -.018em; color: var(--ink) }
.erp-shell ::selection { background: color-mix(in srgb, var(--accent) 30%, transparent) }

/* ---------- En-tête ---------- */
.erp-shell > header {
  min-height: 60px;
  padding: 8px 20px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.erp-shell > header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--brand-gradient); opacity: .85;
}
.erp-shell .brand { gap: 12px; font-weight: 800; letter-spacing: -.01em }
.erp-shell .brand-logo { width: 88px; height: 28px; object-fit: contain; border-radius: 0; box-shadow: none }
.erp-shell .brand-name { display: grid; line-height: 1.15 }
.erp-shell .brand-name small { color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: 0 }
.erp-shell .global-search {
  max-width: 520px; min-height: 40px; padding: 0 6px 0 12px;
  background: color-mix(in srgb, var(--surface-alt) 80%, var(--surface));
  border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.erp-shell .global-search:focus-within { background: var(--surface); border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); box-shadow: var(--ring) }
.erp-shell .global-search input { font-size: .9rem }
.erp-shell .header-actions { gap: 8px }
.erp-shell .header-actions select { min-height: 36px; padding: 6px 30px 6px 10px; border-radius: 10px; font-size: .84rem; font-weight: 650 }

/* Menu du compte : thème, langue et déconnexion regroupés derrière l'avatar. */
.account-menu { position: relative }
.account-menu > summary {
  display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 3px 10px 3px 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  cursor: pointer; list-style: none; font-weight: 700; font-size: .86rem; color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.account-menu > summary::-webkit-details-marker { display: none }
.account-menu > summary:hover, .account-menu[open] > summary { border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); box-shadow: var(--lift) }
.account-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-gradient); color: #fff; font-size: .78rem; font-weight: 850; letter-spacing: .02em;
}
.account-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.account-menu > summary::after { content: ""; width: 7px; height: 7px; margin-left: 2px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px) }
.account-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40; width: 290px; padding: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--lift-strong);
  animation: erp-pop .16s ease-out;
}
.account-panel-head { display: flex; align-items: center; gap: 11px; padding: 8px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px }
.account-panel-head .account-avatar { width: 42px; height: 42px; font-size: .95rem }
.account-panel-head strong, .account-panel-head small { display: block }
.account-panel-head small { color: var(--muted); font-size: .78rem }
.account-panel form { margin: 0 }
.account-panel label:not(.sr-only) { display: block; margin: 8px 8px 4px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase }
.account-panel select { width: 100%; min-height: 38px; border-radius: 10px }
.account-panel .theme-switcher, .account-panel .language-switcher, .account-panel .simple-mode-switch { padding: 0 8px }
.account-panel .simple-mode-switch button { width: 100%; margin-top: 10px }
.account-panel .accounting-guide-switch { padding: 8px 8px 0 }
.account-panel label.accounting-guide-option { display: flex; align-items: flex-start; gap: 10px; margin: 0; color: var(--ink); font-size: .875rem; font-weight: 600; letter-spacing: normal; text-transform: none; cursor: pointer }
.account-panel .accounting-guide-option input { flex: none; margin: 2px 0 0 }
.account-panel .accounting-guide-switch .form-help { margin: 8px 0 4px; color: var(--muted); font-size: .78rem; line-height: 1.5 }
.account-panel .account-logout { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line) }
.account-panel .account-logout button { width: 100%; background: transparent; color: var(--danger); box-shadow: none; border: 1px solid transparent }
.account-panel .account-logout button:hover { background: var(--danger-soft); color: var(--danger) }
.support-button { position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px 0 11px; border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--line)); border-radius: 999px; background: var(--surface); color: var(--blue); font-weight: 700; font-size: .9rem; text-decoration: none; white-space: nowrap }
.support-button:hover, .support-button.active { background: var(--tint, var(--blue-soft)); border-color: var(--blue) }
.support-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.support-button-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 800 }
.company-switcher select { max-width: 210px; border-radius: 999px; padding-left: 14px; background-color: var(--tint); border-color: color-mix(in srgb, var(--blue) 22%, var(--line)); color: var(--blue) }

@keyframes erp-pop { from { opacity: 0; transform: translateY(-4px) scale(.98) } to { opacity: 1; transform: none } }
@keyframes erp-rise { from { transform: translateY(6px) } to { transform: none } }

/* ---------- Barre latérale ---------- */
.erp-shell .app-layout { grid-template-columns: 256px minmax(0, 1fr) }
.erp-shell .sidebar {
  top: 60px; height: calc(100vh - 60px); padding: 16px 12px 26px;
  background: color-mix(in srgb, var(--sidebar-bg, var(--surface)) 88%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 35%, transparent) transparent;
}
.erp-shell .sidebar-section { margin: 20px 10px 6px; color: color-mix(in srgb, var(--muted) 85%, transparent); font-size: .66rem; font-weight: 800; letter-spacing: .12em }
.erp-shell .sidebar .nav-link, .erp-shell .nav-menu-overview-link {
  position: relative; min-height: 36px; padding: 7px 10px; border-radius: 10px;
  color: color-mix(in srgb, var(--ink) 88%, var(--muted)); font-weight: 600; font-size: .86rem;
  transition: background .14s ease, color .14s ease;
}
.erp-shell .nav-menu-overview-link { padding-right: 38px; font-weight: 700 }
.erp-shell .sidebar .nav-link:hover, .erp-shell .nav-menu-overview-link:hover { background: color-mix(in srgb, var(--blue) 7%, transparent); color: var(--blue) }
.erp-shell .sidebar .nav-link.active {
  background: var(--surface); color: var(--blue); box-shadow: var(--lift); font-weight: 750;
}
/* La rubrique ouverte se signale par sa couleur ; seule la page active porte la pastille. */
.erp-shell .nav-menu-overview-link.active { background: transparent; color: var(--blue) }
.erp-shell .nav-menu-overview-link.active:hover { background: color-mix(in srgb, var(--blue) 7%, transparent) }
.erp-shell .sidebar .nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-gradient);
}
.erp-shell .sidebar .nav-link svg, .erp-shell .nav-menu-overview-link .resource-icon { width: 18px; height: 18px; flex: none; opacity: .9 }
.erp-shell .nav-dropdown { margin: 2px 0 6px 18px; padding: 2px 0 2px 8px; border-left: 1px solid var(--line) }
.erp-shell .nav-dropdown .nav-link { min-height: 32px; padding: 5px 9px; font-size: .82rem; font-weight: 550 }
.erp-shell .nav-dropdown .nav-link.active::before { left: -10px; top: 7px; bottom: 7px }
.erp-shell .nav-submenu > summary { padding: 6px 9px; border-radius: 8px; font-size: .74rem; font-weight: 750; letter-spacing: .01em }
.erp-shell .nav-submenu-items { margin-left: 8px }
.erp-shell .nav-count { background: var(--danger); box-shadow: 0 0 0 2px var(--surface) }
.erp-shell .sidebar-help { margin-top: 20px }

/* ---------- Contenu ---------- */
.erp-shell main { max-width: 1320px; margin: 26px auto 60px; padding: 0 28px; animation: erp-rise .28s ease-out }
.erp-shell .erp-back-navigation { margin: 0 0 12px; padding: 0; background: none; border: 0; font-size: .82rem }
.erp-shell .erp-back-navigation a { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px 4px 8px; border-radius: 999px; color: var(--muted); font-weight: 650 }
.erp-shell .erp-back-navigation a:hover { color: var(--blue); background: color-mix(in srgb, var(--blue) 8%, transparent); text-decoration: none }

.erp-shell .card {
  padding: 20px; border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--lift);
}
.erp-shell .data-table-wrap { padding: 0 }
.erp-shell .eyebrow { display: inline-flex; align-items: center; gap: 6px; color: color-mix(in srgb, var(--blue) 85%, var(--muted)); font-size: .7rem; font-weight: 800; letter-spacing: .11em }
.erp-shell .muted { color: var(--muted) }
/* Liens simples : couleur du thème, sans jamais primer sur le style d'un composant. */
:where(.erp-shell main) a { color: var(--blue); text-underline-offset: 3px; text-decoration-thickness: 1px }
:where(.erp-shell main) a:hover { color: var(--blue-hover) }
.erp-shell .card > .eyebrow + h1, .erp-shell .card > .eyebrow + h2 { margin-top: 2px }

/* En-têtes de page */
.erp-shell .hero h1, .erp-shell .list-heading h1, .erp-shell .top-actions h1 { font-weight: 820; letter-spacing: -.028em; line-height: 1.12 }
.erp-shell .hero h1 { font-size: clamp(1.9rem, 3vw, 2.5rem) }
.erp-shell .list-heading { align-items: flex-end; margin-bottom: 16px }
.erp-shell .list-heading h1 { font-size: clamp(1.55rem, 2.4vw, 1.95rem) }
.erp-shell .list-heading p { font-size: .84rem }
.erp-shell .list-heading > div:first-child p:first-of-type {
  display: inline-flex; align-items: center; margin-top: 4px; padding: 2px 10px; border-radius: 999px;
  background: var(--tint); color: var(--blue); font-weight: 700; font-size: .76rem;
}
.erp-shell .top-actions h1 { font-size: clamp(1.5rem, 2.4vw, 1.9rem); margin: 0 0 4px }
/* Titre et boutons d'en-tête : le titre garde sa largeur ; une barre de boutons trop longue
   passe sous le titre au lieu de l'écraser. */
.erp-shell :is(.top-actions, .list-heading, .hero:has(> .detail-actions:last-child)) { flex-wrap: wrap }
.erp-shell :is(.top-actions, .list-heading, .hero:has(> .detail-actions:last-child)) > :first-child { flex: 1 1 340px; min-width: 0 }
.erp-shell :is(.top-actions, .list-heading) > :last-child:not(:first-child), .erp-shell .hero > .detail-actions:last-child:not(:first-child) { flex: 0 1 auto; max-width: 100%; margin-left: auto }

/* Boutons */
/* Boutons : même priorité que les règles génériques « button » / « .button » qu'ils remplacent,
   jamais plus — un onglet ou un bouton propre à un écran garde son propre style. */
:where(.erp-shell) .button, :where(.erp-shell) button:where(:not(.list-row-action, .maddie-chat-bubble-close, .maddie-quick-choice, .maddie-floating-assistant)) {
  min-height: 36px; padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: .86rem; letter-spacing: -.005em;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 10%, transparent), inset 0 1px 0 color-mix(in srgb, #fff 14%, transparent);
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
:where(.erp-shell) .button:where(:not(.secondary, .ghost, .danger, .icon-action)), :where(.erp-shell) button:where(:not(.secondary, .ghost, .danger, .list-row-action, .maddie-chat-bubble-close, .maddie-quick-choice, .maddie-floating-assistant)) {
  background: var(--button-gradient); background-size: 160% 100%; background-position: 0 0; color: var(--button-ink, #fff); border: 0;
}
:where(.erp-shell) .button:where(:not(.secondary, .ghost, .danger, .icon-action)):hover, :where(.erp-shell) button:where(:not(.secondary, .ghost, .danger, .list-row-action, .maddie-chat-bubble-close, .maddie-quick-choice, .maddie-floating-assistant)):hover {
  background-position: 100% 0; box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--blue) 70%, transparent); transform: translateY(-1px);
}
:where(.erp-shell) .button:active, :where(.erp-shell) button:active { transform: translateY(0) }
:where(.erp-shell) .secondary {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent);
}
:where(.erp-shell) .secondary:hover { background: var(--tint); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 30%, var(--line)) }
:where(.erp-shell) .ghost { background: transparent; box-shadow: none; color: var(--blue) }
.erp-shell .button:focus-visible, .erp-shell button:focus-visible, .erp-shell a:focus-visible, .erp-shell summary:focus-visible { outline: none; box-shadow: var(--ring) }

/* Champs */
.erp-shell :where(input:not([type=checkbox], [type=radio], [type=file], [type=range]), select, textarea) {
  min-height: 38px; padding: 8px 11px; border: 1px solid color-mix(in srgb, var(--input-border) 70%, var(--line)); border-radius: 10px;
  background-color: var(--surface); color: var(--ink); font: inherit; font-size: .9rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.erp-shell :where(input:not([type=checkbox], [type=radio]), select, textarea):hover { border-color: color-mix(in srgb, var(--blue) 30%, var(--input-border)) }
.erp-shell :where(input:not([type=checkbox], [type=radio]), select, textarea):focus { outline: none; border-color: color-mix(in srgb, var(--blue) 60%, var(--input-border)); box-shadow: var(--ring) }
.erp-shell input[type=checkbox], .erp-shell input[type=radio] { accent-color: var(--blue); width: 16px; height: 16px }
.erp-shell input::placeholder, .erp-shell textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent) }
.erp-shell label { font-weight: 650; font-size: .86rem }
.erp-shell .global-search input, .erp-shell .search-box input { border: 0; box-shadow: none; background: transparent; min-height: 0 }
.erp-shell .global-search input:focus, .erp-shell .search-box input:focus { box-shadow: none }

/* Barre d'outils de liste */
.erp-shell .search-box { min-height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 5%, transparent); transition: border-color .15s ease, box-shadow .15s ease }
.erp-shell .search-box:focus-within { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); box-shadow: var(--ring) }
.erp-shell .search-box button { min-height: 32px; margin: 3px; border-radius: 9px }
.erp-shell .filter-panel, .erp-shell .list-toolbar > .column-panel { border-radius: 12px; background: var(--surface); box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 5%, transparent) }
.erp-shell .filter-panel summary, .erp-shell .column-panel > summary { color: var(--ink) }

/* Tableaux */
.erp-shell table { background: var(--surface) }
.erp-shell th, .erp-shell td { border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent) }
.erp-shell thead th { background: color-mix(in srgb, var(--surface-alt) 70%, var(--surface)); color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase }
.erp-shell tbody th { background: transparent }
.erp-shell .data-table-wrap, .erp-shell .card[style*="padding:0"] { border-radius: var(--radius-lg); overflow: auto }
.erp-shell .data-table thead th { position: sticky; top: 0; z-index: 2; backdrop-filter: blur(6px); box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--line) 90%, transparent) }
/* En-tête toujours visible : une liste plus haute que l'écran défile dans son cadre, sous l'en-tête
   qui reste en place ; le cadre garde aussi le défilement horizontal des tableaux larges. */
.erp-shell .data-table-wrap:has(> .data-table) { max-height: max(320px, calc(100vh - 110px)) }
.erp-shell .data-table thead th.actions-cell { z-index: 3 }
.erp-shell .data-table tbody tr, .erp-shell .card > table tbody tr { transition: background .12s ease }
.erp-shell .data-table tbody tr:hover, .erp-shell .card > table tbody tr:hover { background: color-mix(in srgb, var(--blue) 4%, var(--surface)) }
.erp-shell .data-table td { font-size: .86rem }
.erp-shell tbody tr:last-child td { border-bottom: 0 }
.erp-shell .list-row-action { border-radius: 9px }
.erp-shell .list-row-action:hover { background: var(--tint) }
.erp-shell .pagination a, .erp-shell .pagination span { border-radius: 9px }

/* Statuts, pastilles, messages */
.erp-shell .list-status-chip { border-radius: 999px; font-weight: 650 }
.erp-shell .messages li { border-radius: var(--radius); box-shadow: var(--lift); animation: erp-rise .25s ease-out }
.erp-shell .onboarding-hint { border-radius: var(--radius) }
.erp-shell .list-empty-state {
  flex-direction: column; justify-content: center; gap: 14px; min-height: 320px; padding: 40px 24px; text-align: center;
  border-style: dashed; background: color-mix(in srgb, var(--surface) 70%, transparent); box-shadow: none;
}
.erp-shell .list-empty-state p { max-width: 460px; margin-left: auto; margin-right: auto }
.erp-shell .list-empty-icon { flex: none; width: 56px; height: 56px; border-radius: 18px; background: var(--brand-gradient); color: #fff; font-size: 1.4rem; box-shadow: var(--lift) }
.erp-shell .list-empty-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.erp-shell .guide-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; color: var(--muted); font-size: .82rem }
.erp-shell .guide-hint summary { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; background: var(--purple-soft); color: var(--purple); font-weight: 700; cursor: pointer; list-style: none }
.erp-shell .guide-hint summary::-webkit-details-marker { display: none }
.erp-shell .guide-hint[open] { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface) }
.erp-shell .guide-hint p { margin: 10px 0 0 }

/* Formulaires : sections en cartes douces */
.erp-shell .erp-form-fields { gap: 4px 28px }
.erp-shell .form-tabs { border-radius: 12px }
.erp-shell .required-marker { color: var(--danger) }

/* Fiches : le lien de retour suffit, le surtitre identique est masqué. */
.erp-shell .detail-toolbar .back-link { display: inline-flex; margin-bottom: 10px; padding: 4px 10px 4px 8px; border-radius: 999px; color: var(--muted); font-size: .82rem; font-weight: 650; text-decoration: none }
.erp-shell .detail-toolbar .back-link:hover { color: var(--blue); background: color-mix(in srgb, var(--blue) 8%, transparent) }
.erp-shell .detail-toolbar .back-link + .eyebrow { display: none }
.erp-shell .detail-toolbar h1 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 820; letter-spacing: -.03em }
.erp-shell .detail-status { border-radius: 999px }
.erp-shell .detail-grid > div, .erp-shell .detail-section { border-radius: var(--radius) }
.erp-shell .detail-lines { border-radius: var(--radius-lg) }

/* Pages de rubrique (cockpit) */
.erp-shell .cockpit-link { border-radius: 12px; transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease }
.erp-shell .cockpit-link:hover { transform: translateY(-1px); box-shadow: var(--lift) }
.erp-shell .cockpit-section-symbol { background: var(--brand-gradient); color: #fff; box-shadow: var(--lift) }

/* Hub Paramètres */
.erp-shell .settings-tab { border-radius: 999px }
.erp-shell .settings-tab.active { background: var(--button-gradient); color: var(--button-ink, #fff); border-color: transparent; box-shadow: var(--lift) }
.erp-shell .settings-link { border-radius: 14px; transition: transform .14s ease, box-shadow .14s ease, background .14s ease }
.erp-shell .settings-link:hover { transform: translateY(-1px); box-shadow: var(--lift) }

/* Accès au téléphone : aucune génération de QR dans la barre générale. */
.erp-phone-link{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:38px;padding:7px 10px;border:1px solid var(--line);border-radius:10px;font-size:.82rem;font-weight:700;white-space:nowrap}
.erp-phone-link svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
.erp-phone-link:hover,.erp-phone-link.active{background:var(--blue-soft);color:var(--blue)}
.erp-sidebar-backdrop[hidden]{display:none}
.erp-sidebar-backdrop{display:none}
@media(max-width:1200px){.erp-phone-link span{display:none}}
@media(min-width:901px) and (max-width:1100px){.erp-shell>header .account-name,.erp-shell>header .support-button-label{display:none}}

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .erp-shell>header{display:grid;grid-template-columns:minmax(0,1fr) 44px 54px;gap:8px}
  .erp-shell>header>div:first-child{grid-column:1 / 3;grid-row:1;min-width:0}
  .erp-shell>header>div:first-child>strong{min-width:0}
  .erp-shell>header .header-actions{display:contents}
  .erp-shell>header .account-menu{grid-column:3;grid-row:1}
  .erp-shell>header .global-search{grid-column:1;grid-row:2;width:100%;max-width:none;min-width:0;order:initial}
  .erp-shell>header .global-search kbd{display:none}
  .erp-shell>header .erp-phone-link{grid-column:2;grid-row:2;padding:0}
  .erp-shell>header .support-button{grid-column:3;grid-row:2;justify-content:center;padding:0}
  .erp-shell>header .support-button-label{display:none}
  .erp-shell>header .brand{min-width:0}
  .erp-shell>header .brand-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .erp-shell .account-panel .company-switcher select{width:100%;max-width:100%;min-height:44px}
  .erp-shell .account-panel{position:fixed;left:12px;right:12px;top:calc(var(--erp-header-height,60px) + 6px);width:auto}
  .erp-shell .app-layout { grid-template-columns: minmax(0, 1fr) }
  .erp-shell .sidebar { top: var(--erp-header-height,60px); height: calc(100dvh - var(--erp-header-height,60px)); overscroll-behavior:contain; padding-bottom:max(26px,env(safe-area-inset-bottom)); background: var(--sidebar-bg, var(--surface)); box-shadow: 18px 0 40px -24px color-mix(in srgb, var(--ink) 45%, transparent) }
  .erp-shell.sidebar-open{overflow:hidden}
  .erp-shell .erp-sidebar-backdrop:not([hidden]){display:block;position:fixed;z-index:30;inset:var(--erp-header-height,60px) 0 0;min-height:0;width:100%;padding:0;border:0;border-radius:0;background:rgba(15,23,42,.38)}
  .erp-shell .mobile-menu,.erp-shell .erp-phone-link,.erp-shell .support-button,.erp-shell .account-menu>summary{min-width:44px;min-height:44px}
  .erp-shell .sidebar .nav-link,.erp-shell .nav-menu-overview-link,.erp-shell .sidebar summary{min-height:44px}
  .erp-phone-link span{display:none}
  .erp-shell input:not([type=checkbox]):not([type=radio]),.erp-shell select,.erp-shell textarea{font-size:16px}
  .erp-shell .global-search input{min-height:44px;font-size:16px}
  .erp-shell .global-search button{width:44px;height:44px;min-height:44px}
  .erp-shell .list-row-action{min-width:44px;min-height:44px}
  .erp-shell .account-panel{max-height:calc(100dvh - var(--erp-header-height,60px) - 24px);overflow-y:auto;overscroll-behavior:contain}
  .account-name { display: none }
  .account-menu > summary { padding-right: 8px }
}
@media (max-width: 650px) {
  .erp-shell .list-heading { align-items: stretch; text-align: left }
  .erp-shell .list-heading > div:last-child { justify-content: flex-start }
  .erp-shell main { margin-top: 16px; padding: 0 14px }
  .erp-shell > header { padding: 8px 12px }
  .erp-shell > header .brand-logo{display:none!important}
  .erp-shell .brand-name small { display: none }
  .company-switcher select { max-width: 150px }
  .support-button { padding: 0 10px } .support-button-label { display: none }
  .account-panel { position: fixed; left: 12px; right: 12px; top: calc(var(--erp-header-height,60px) + 6px); width: auto }
  .erp-shell .card { padding: 16px; border-radius: 14px }
  .erp-shell .portal-validations .data-table-wrap { margin: 0 -16px -16px }
  /* Surtitres longs et boutons d'en-tête : retour à la ligne plutôt que débordement. */
  .erp-shell .eyebrow { display: block; line-height: 1.6 }
  .erp-shell .eyebrow .edu-badge { display: inline-block; max-width: 100%; margin-top: 4px; white-space: normal }
  .erp-shell .hero .detail-actions { justify-content: flex-start }
  .erp-shell .hero .detail-actions .button { white-space: normal }
}
@media (prefers-reduced-motion: reduce) {
  .erp-shell main, .account-panel, .erp-shell .messages li { animation: none }
  .erp-shell *, .erp-shell *::before, .erp-shell *::after { transition-duration: .01ms !important }
}

/* ---------- Harmonisation des écrans spécialisés ---------- */
/* Cartes empilées directement dans la page : même respiration partout. */
.erp-shell main > .card + .card, .erp-shell main > .card + section, .erp-shell main > section + .card { margin-top: 18px }
/* Lien de retour autonome : même pastille discrète que sur les fiches. */
.erp-shell main > .back-link { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 12px; padding: 4px 10px 4px 8px; border-radius: 999px; color: var(--muted); font-size: .82rem; font-weight: 650; text-decoration: none }
.erp-shell main > .back-link:hover { color: var(--blue); background: color-mix(in srgb, var(--blue) 8%, transparent) }
/* Tableaux vides : message centré et apaisé plutôt qu'une ligne nue. */
.erp-shell td.empty-state, .erp-shell td.empty { padding: 34px 20px; text-align: center; color: var(--muted); font-size: .88rem; background: color-mix(in srgb, var(--surface-alt) 45%, var(--surface)) }
/* Champ fichier : bouton assorti aux boutons secondaires. */
.erp-shell input[type=file] { padding: 6px; border: 1px dashed color-mix(in srgb, var(--blue) 30%, var(--line)); border-radius: 12px; background: var(--tint); color: var(--muted); font-size: .86rem; max-width: 100% }
.erp-shell input[type=file]::file-selector-button { margin-right: 12px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; transition: border-color .15s ease, color .15s ease }
.erp-shell input[type=file]::file-selector-button:hover { border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); color: var(--blue) }
/* Assistant Luni : pastille compacte qui ne masque plus le contenu ; le libellé s'ouvre au survol. */
.erp-shell .maddie-floating-assistant { gap: 0; padding: 5px; box-shadow: var(--lift-strong); transition: gap .18s ease, padding .18s ease, border-color .15s ease }
.erp-shell .maddie-floating-avatar { width: 44px; height: 44px }
.erp-shell .maddie-floating-copy { max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0; transition: max-width .22s ease, opacity .18s ease }
.erp-shell .maddie-floating-copy strong, .erp-shell .maddie-floating-copy span { display: block }
.erp-shell .maddie-floating-copy span { color: var(--muted); font-size: .78rem; font-weight: 600 }
.erp-shell .maddie-floating-assistant:is(:hover, :focus-visible, [aria-expanded="true"]) { gap: 10px; padding-right: 16px }
.erp-shell .maddie-floating-assistant:is(:hover, :focus-visible, [aria-expanded="true"]) .maddie-floating-copy { max-width: 220px; opacity: 1 }
.erp-shell:has(.maddie-floating-assistant) main { margin-bottom: 96px }
.erp-shell .hero .detail-actions { flex-wrap: wrap }
/* Filtre de statut remis à zéro, sous les repères. */
.erp-shell .portal-filter-reset { margin: -8px 0 14px; font-size: .84rem; font-weight: 650 }
.erp-shell .portal-validations h2 { margin: 2px 0 12px }
.erp-shell .portal-validations .data-table-wrap { margin: 0 -20px -20px; border-top: 1px solid color-mix(in srgb, var(--line) 75%, transparent); border-radius: 0 0 var(--radius-lg) var(--radius-lg) }
.erp-shell main > .card > h2:first-child, .erp-shell main > section.card > h2:first-child { margin-top: 0 }
/* Les en-têtes internes aux pages ne reprennent pas le style de la barre supérieure
   (fond, bordure, position collante) : chaque composant garde son propre habillage. */
:where(.erp-shell main) header { position: static; z-index: auto; min-height: 0; padding: 0; background: transparent; border-bottom: 0 }
/* Colonne d'actions : juste la place de ses icônes, collée à l'identité de la ligne. */
.erp-shell .data-table .actions-cell { width: 1%; padding-left: 14px; padding-right: 10px }
/* Statut dans une ligne : même pastille que les repères, sans effet de lien. */
.erp-shell .list-status-cell { padding: 3px 9px; font-size: .78rem; font-weight: 700 }
.erp-shell .list-status-cell:hover { border-color: transparent; box-shadow: none }
/* Ligne cliquable : elle ouvre la fiche, comme le lien « Voir ». */
.erp-shell .data-table tr.list-row-link { cursor: pointer }
.erp-shell .data-table tr.list-row-link :is(input, label) { cursor: default }
/* Recherche instantanée : fine barre animée sous le champ pendant la mise à jour de la liste. */
.erp-shell .search-box { position: relative; overflow: hidden }
.erp-shell .search-box::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 40%; background: var(--brand-gradient); opacity: 0; transform: translateX(-100%) }
.erp-shell .search-box.htmx-request::after { opacity: 1; animation: erp-search-progress 1s ease-in-out infinite }
@keyframes erp-search-progress { from { transform: translateX(-100%) } to { transform: translateX(260%) } }
@media (prefers-reduced-motion: reduce) { .erp-shell .search-box.htmx-request::after { animation: none; width: 100% } }
/* Action d'en-tête de liste envoyée en POST : reste alignée avec les autres boutons. */
.erp-shell .list-inline-form { display: inline-flex; margin: 0 }
/* Sélecteur d'établissement : même pastille que la société, avec son propre accent. */
.establishment-switcher select { max-width: 260px; background-color: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); color: var(--ink) }
@media (max-width: 650px) { .establishment-switcher select { max-width: 150px } }

/* Import d'un calendrier scolaire officiel */
.calendar-import-dialog{width:min(620px,calc(100vw - 32px));max-height:min(86vh,760px);padding:0;border:1px solid var(--line);border-radius:16px;color:var(--ink);background:var(--surface);box-shadow:0 24px 70px rgba(10,20,40,.3)}
.calendar-import-dialog::backdrop{background:rgba(10,20,40,.48)}
.calendar-import-form{display:flex;flex-direction:column;gap:12px;padding:22px 22px 18px;max-height:inherit;box-sizing:border-box;overflow:auto}
.calendar-import-head{display:flex;justify-content:space-between;align-items:flex-start;gap:14px}
.calendar-import-head h2{margin:0 0 6px;font-size:1.2rem}
.calendar-import-head p{margin:0;color:var(--muted);font-size:.9rem;line-height:1.45}
.calendar-import-close{flex:0 0 auto;width:34px;height:34px;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--surface-alt);color:var(--muted);font-size:1.25rem;line-height:1;cursor:pointer}
.calendar-import-form label{font-weight:700;font-size:.86rem}
.calendar-import-form select{width:100%}
.calendar-import-preview{display:flex;flex-direction:column;gap:10px}
.calendar-import-preview[hidden]{display:none}
.calendar-import-source{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin:0;font-size:.8rem}
.calendar-import-source a{color:var(--blue);font-weight:700}
.calendar-import-badge{display:inline-flex;align-items:center;padding:3px 9px;border-radius:999px;background:var(--surface-alt);color:var(--muted);font-weight:650}
.calendar-import-badge.is-verified{background:var(--success-soft);color:var(--success)}
.calendar-import-badge.is-pending{background:var(--warn-soft);color:var(--warn);border:1px solid var(--warn-line)}
.calendar-import-description{margin:0;color:var(--muted);font-size:.86rem}
.calendar-import-years{list-style:none;margin:0;padding:0;border:1px solid var(--line);border-radius:12px;overflow:hidden}
.calendar-import-years>li{padding:11px 14px;border-top:1px solid var(--line)}
.calendar-import-years>li:first-child{border-top:0}
.calendar-import-year{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.calendar-import-year span{font-size:.84rem;font-weight:700}
.calendar-import-years .is-new{color:var(--blue)}
.calendar-import-years .is-done{color:var(--success)}
.calendar-import-years .is-warning{color:var(--warn)}
.calendar-import-years .is-muted{color:var(--muted);font-weight:500}
.calendar-import-years details{margin-top:6px}
.calendar-import-years summary{cursor:pointer;color:var(--muted);font-size:.8rem}
.calendar-import-years details ul{list-style:none;margin:6px 0 0;padding:0;max-height:220px;overflow:auto}
.calendar-import-years details li{display:flex;justify-content:space-between;gap:12px;padding:5px 0;border-top:1px dashed var(--line);font-size:.82rem}
.calendar-import-years time{color:var(--muted);white-space:nowrap;font-variant-numeric:tabular-nums}
.calendar-import-empty{margin:0;padding:14px;border-radius:12px;background:var(--surface-alt);color:var(--muted)}
.calendar-import-actions{display:flex;justify-content:flex-end;gap:8px;padding-top:6px}
@media(max-width:560px){.calendar-import-form{padding:18px 16px}.calendar-import-actions{flex-direction:column-reverse}.calendar-import-actions button{width:100%}}
