/* ═══════════════════════════════════════════════════════
   Portail client — Design System
   Direction : Atelier de pilotage
   ═══════════════════════════════════════════════════════ */

/* ── VARIABLES ─────────────────────────────────────────── */
:root {
  --bg:              #f6f4ef;
  --card:            #fffdfa;
  --card2:           #f1ece4;
  --text:            #171717;
  --muted:           #6b665c;
  --border:          #e3ded5;
  --border-strong:   #cfc7ba;
  --line:            var(--border);
  --surface-2:       var(--card2);

  /* Palette principale */
  --primary:         #1d1b17;
  --primary-hover:   #0f0e0b;
  --primary-weak:    rgba(29,27,23,.07);
  --accent:          #b86b35;
  --accent-hover:    #955226;
  --accent-weak:     #f4e4d8;

  /* Statuts */
  --danger:          #b42318;
  --danger-weak:     #f7e3e0;
  --success:         #237a57;
  --success-weak:    #e5f0ec;
  --warning:         #b7791f;
  --warning-weak:    #fff3d7;
  --info:            #2f6f9f;
  --info-weak:       #e8eef6;

  /* Ombres */
  --shadow-xs:       0 1px 2px rgba(73,57,35,.05);
  --shadow-sm:       0 1px 3px rgba(73,57,35,.07);
  --shadow:          0 8px 22px rgba(73,57,35,.08);
  --shadow-md:       0 14px 34px rgba(73,57,35,.10);
  --shadow-lg:       0 22px 52px rgba(73,57,35,.14);

  /* Géométrie */
  --radius-xs:       6px;
  --radius-sm:       8px;
  --radius:          8px;
  --radius-lg:       10px;
  --radius-xl:       12px;

  /* Layout */
  --sidebar-width:   260px;
  --sidebar-mini:    72px;
  --topbar-height:   58px;
  --leftmenu-width:  var(--sidebar-width);
}

html.theme-dark {
  --bg:           #10100e;
  --card:         #181713;
  --card2:        #211f1a;
  --text:         #f1eee7;
  --muted:        #b4aa9a;
  --border:       #353025;
  --border-strong: #4a4235;
  --line:         var(--border);
  --surface-2:    var(--card2);

  --primary:       #f1eee7;
  --primary-hover: #ffffff;
  --primary-weak:  rgba(241,238,231,.08);
  --accent:        #d28a54;
  --accent-hover:  #e6a66e;
  --accent-weak:   rgba(210,138,84,.18);

  --danger:       #f08b80;
  --danger-weak:  rgba(240,139,128,.14);
  --success:      #75c49e;
  --success-weak: rgba(117,196,158,.14);
  --warning:      #d7a34b;
  --warning-weak: rgba(215,163,75,.14);
  --info:         #82afd1;
  --info-weak:    rgba(130,175,209,.14);

  --shadow-xs:    0 1px 2px rgba(0,0,0,.3);
  --shadow-sm:    0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow:       0 4px 12px rgba(0,0,0,.45);
  --shadow-md:    0 8px 24px rgba(0,0,0,.5);
  --shadow-lg:    0 16px 40px rgba(0,0,0,.6);
}

/* ── KEYFRAMES ──────────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px) }
  to   { opacity: 1; transform: translateY(0) }
}
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-14px) }
  to   { opacity: 1; transform: translateY(0) }
}
@keyframes fadeIn {
  from { opacity: 0 }
  to   { opacity: 1 }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.93) }
  to   { opacity: 1; transform: scale(1) }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px) }
  to   { opacity: 1; transform: translateX(0) }
}
@keyframes pulseBadge {
  0%   { box-shadow: 0 0 0 0   rgba(245,158,11,.55) }
  60%  { box-shadow: 0 0 0 7px rgba(245,158,11,0)   }
  100% { box-shadow: 0 0 0 0   rgba(245,158,11,0)   }
}
@keyframes spinOnce {
  from { transform: rotate(0deg) }
  to   { transform: rotate(360deg) }
}
@keyframes shimmer {
  0%   { background-position: -400px 0 }
  100% { background-position:  400px 0 }
}

/* ── REDUCED MOTION ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:       .01ms !important;
    animation-iteration-count: 1   !important;
    transition-duration:      .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── BASE ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box }
html, body { height: 100%; margin: 0; padding: 0 }

body {
  font-family: "Aptos", "Segoe UI Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
               Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 0.9375rem;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none }
a:hover { text-decoration: underline }

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; line-height: 1.3 }
h1 { font-size: 1.18rem; letter-spacing: -.01em; text-wrap: normal }
h2 { font-size: 1.1rem;  letter-spacing: 0 }
h3 { font-size: .975rem }
h4 { font-size: .9rem }
p  { margin: 0 0 10px }

/* ── LAYOUT : sidebar + contenu ─────────────────────────── */
body.has-leftmenu {
  padding-left: var(--sidebar-width);
  transition: padding-left .2s ease;
}
body.has-leftmenu.leftmenu-collapsed {
  padding-left: var(--sidebar-mini);
}

/* ── SIDEBAR ────────────────────────────────────────────── */
.platform-leftmenu {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #0d1117;
  color: #e5e7eb;
  z-index: 200;
  overflow: hidden;
  transition: width .2s ease;
  border-right: 1px solid rgba(255,255,255,.04);
}
html.theme-dark .platform-leftmenu {
  background: #090e17;
  border-right-color: rgba(255,255,255,.05);
}

body.leftmenu-collapsed .platform-leftmenu {
  width: var(--sidebar-mini);
}

/* Header/Brand */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
  height: var(--topbar-height);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-decoration: none;
  min-width: 0;
}

.sidebar-brand-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f59e0b, #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: .8rem;
  color: #fff;
  letter-spacing: -.5px;
  box-shadow: 0 3px 10px rgba(245,158,11,.3);
}

.sidebar-brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 132px;
  height: 32px;
  object-fit: contain;
  object-position: left center;
}

body.leftmenu-collapsed .sidebar-brand-logo {
  width: 32px;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: .95rem;
  color: #f9fafb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-xs);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  transition: background .14s, color .14s, transform .2s ease;
}
.sidebar-collapse-btn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
body.leftmenu-collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
}

/* Nav */
.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 3px }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px }

.sidebar-group { margin-bottom: 2px }
.sidebar-group + .sidebar-group { margin-top: 6px }

.sidebar-group-label {
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.28);
  padding: 6px 10px 3px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .18s;
}

body.leftmenu-collapsed .sidebar-group-label {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.sidebar-sep {
  height: 1px;
  background: rgba(255,255,255,.05);
  margin: 5px 2px;
}

/* Links */
.platform-leftmenu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 500;
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  transition: background .12s, color .12s, border-color .12s;
  position: relative;
}
.platform-leftmenu-link:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}
.platform-leftmenu-link.active {
  background: rgba(245,158,11,.16);
  border-color: rgba(245,158,11,.25);
  color: #fef3c7;
  font-weight: 600;
}
.platform-leftmenu-link.active .sidebar-link-icon {
  color: #f59e0b;
}
.platform-leftmenu-link-brief {
  background: rgba(210,138,84,.14);
  border-color: rgba(210,138,84,.24);
  color: #fdebd7;
}
.platform-leftmenu-link-brief .sidebar-link-icon {
  color: #e6a66e;
}

.sidebar-link-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: .82rem;
  color: rgba(255,255,255,.38);
  transition: color .12s;
}
.platform-leftmenu-link:hover .sidebar-link-icon {
  color: rgba(255,255,255,.7);
}

.sidebar-link-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link-badge {
  flex-shrink: 0;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: pulseBadge 2.5s 1.8s ease infinite;
}

/* Collapsed */
body.leftmenu-collapsed .platform-leftmenu-link {
  justify-content: center;
  gap: 0;
  padding: 9px;
}
body.leftmenu-collapsed .sidebar-link-label,
body.leftmenu-collapsed .sidebar-link-badge {
  opacity: 0; width: 0; overflow: hidden;
}
body.leftmenu-collapsed .sidebar-brand-name {
  opacity: 0; width: 0; overflow: hidden;
}

/* Footer */
.sidebar-footer {
  flex-shrink: 0;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(255,255,255,.05);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 4px;
}

.sidebar-user-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .76rem;
  color: #fff;
  text-transform: uppercase;
}

.sidebar-user-info {
  flex: 1 1 auto;
  overflow: hidden;
  transition: opacity .18s;
}
.sidebar-user-info strong {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: #f9fafb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-info span {
  font-size: .72rem;
  color: rgba(255,255,255,.38);
}

body.leftmenu-collapsed .sidebar-user {
  justify-content: center;
  padding: 7px;
}
body.leftmenu-collapsed .sidebar-user-info {
  opacity: 0; width: 0; overflow: hidden;
}

.sidebar-theme-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: rgba(255,255,255,.5);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  text-align: left;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-theme-btn:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.85);
}

html.theme-dark .sidebar-theme-btn .sidebar-theme-icon-sun { display: none }
html:not(.theme-dark) .sidebar-theme-btn .sidebar-theme-icon-moon { display: none }
.sidebar-theme-icon-sun { color: #f59e0b }
.sidebar-theme-icon-moon { color: #94a3b8 }

body.leftmenu-collapsed .sidebar-theme-btn {
  justify-content: center;
  padding: 9px;
}
body.leftmenu-collapsed .sidebar-theme-btn .sidebar-link-label {
  opacity: 0; width: 0; overflow: hidden;
}

.platform-leftmenu-link-logout {
  color: rgba(255,255,255,.45);
}
.platform-leftmenu-link-logout:hover {
  background: rgba(220,38,38,.15) !important;
  border-color: rgba(248,113,113,.2) !important;
  color: #fca5a5 !important;
}
.platform-leftmenu-link-logout .sidebar-link-icon {
  color: rgba(248,113,113,.5);
}

.leftmenu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 190;
  transition: opacity .22s, visibility 0s linear .22s;
}
body.leftmenu-open .leftmenu-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .22s, visibility 0s linear 0s;
}

/* ── PAGE ENTRANCE — cascade automatique des enfants de <main> ── */
main.page-animated > * {
  animation: fadeSlideUp .5s cubic-bezier(.22,1,.36,1) both;
}
main.page-animated > *:nth-child(1)  { animation-delay: .04s }
main.page-animated > *:nth-child(2)  { animation-delay: .11s }
main.page-animated > *:nth-child(3)  { animation-delay: .18s }
main.page-animated > *:nth-child(4)  { animation-delay: .25s }
main.page-animated > *:nth-child(5)  { animation-delay: .32s }
main.page-animated > *:nth-child(6)  { animation-delay: .38s }
main.page-animated > *:nth-child(7)  { animation-delay: .44s }
main.page-animated > *:nth-child(8)  { animation-delay: .50s }

/* Scroll-triggered — ajouté par JS via IntersectionObserver */
[data-anim] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .48s cubic-bezier(.22,1,.36,1),
              transform .48s cubic-bezier(.22,1,.36,1);
}
[data-anim].anim-visible { opacity: 1; transform: translateY(0) }
[data-anim][data-delay="1"] { transition-delay: .06s }
[data-anim][data-delay="2"] { transition-delay: .13s }
[data-anim][data-delay="3"] { transition-delay: .20s }
[data-anim][data-delay="4"] { transition-delay: .27s }
[data-anim][data-delay="5"] { transition-delay: .34s }
[data-anim][data-delay="6"] { transition-delay: .41s }

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-height);
  animation: fadeSlideDown .35s cubic-bezier(.22,1,.36,1) both;
}
html.theme-dark .topbar {
  background: rgba(13,17,23,.95);
  border-bottom-color: var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 20px;
}

.topbar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .95rem;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.topbar-toggle:hover {
  background: var(--accent-weak);
  color: var(--accent-hover);
}

.topbar-spacer { flex: 1 1 auto }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-notif-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: .9rem;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.topbar-notif-btn:hover {
  background: var(--accent-weak);
  color: var(--accent-hover);
  text-decoration: none;
}
.topbar-notif-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 800;
  min-width: 15px;
  height: 15px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  animation: pulseBadge 2.5s 1.5s ease infinite;
}

.nav.nav-centered { display: none }

/* ── BACK BUTTON ────────────────────────────────────────── */
.page-back-wrap {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
}
.page-back-wrap.page-back-wrap-split {
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.page-back-wrap-full  { margin: 0 20px 14px }
.page-back-btn i      { font-size: .8rem }

/* ── CONTAINER ──────────────────────────────────────────── */
.container {
  max-width: none;
  margin: 0 auto;
  padding: 24px 28px;
}
.main-fullwidth { padding: 16px 0 24px }
.main-fullwidth-flash { margin: 14px 28px }
body.iframe-mode {
  padding: 0;
  margin: 0;
  background: #fff;
}
body.iframe-mode main {
  padding: 16px;
  margin: 0;
  max-width: 100%;
}
body.iframe-mode .page-back-wrap,
body.iframe-mode #chat-bubble,
body.iframe-mode #chat-panel {
  display: none;
}
html.theme-dark body.iframe-mode {
  background: var(--bg);
}

/* ── FLASH MESSAGES ─────────────────────────────────────── */
.flash {
  margin: 0 0 16px;
  padding: 11px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: .88rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.flash-success {
  border-color: rgba(22,163,74,.28);
  background: var(--success-weak);
  color: #14532d;
}
.flash-error {
  border-color: rgba(220,38,38,.28);
  background: var(--danger-weak);
  color: #7f1d1d;
}
.flash-info {
  border-color: rgba(37,99,235,.22);
  background: var(--info-weak);
}
html.theme-dark .flash-success { color: #86efac }
html.theme-dark .flash-error   { color: #fca5a5 }
.flash-toast-region {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 20px;
  margin: 0;
  z-index: 1200;
  width: min(420px, calc(100vw - 40px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}
.flash-toast {
  position: relative;
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 11px;
  padding: 13px 12px 13px 15px;
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 8px 24px rgba(9,20,37,.18);
  pointer-events: auto;
  animation: flash-toast-in .2s ease-out both;
}
.flash-toast--success { border-color: rgba(22,163,74,.42); }
.flash-toast--error { border-color: rgba(220,38,38,.42); }
.flash-toast--warning { border-color: rgba(180,120,20,.46); }
.flash-toast--info { border-color: rgba(37,99,235,.35); }
.flash-toast-icon { margin-top: 2px; color: var(--accent); }
.flash-toast--success .flash-toast-icon { color: #278b60; }
.flash-toast--error .flash-toast-icon { color: #bd3d3d; }
.flash-toast--warning .flash-toast-icon { color: #b27718; }
.flash-toast-message { line-height: 1.4; overflow-wrap: anywhere; }
.flash-toast-dismiss {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -5px -4px 0 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.flash-toast-dismiss:hover { background: var(--card2); color: var(--text); }
.flash-toast-dismiss:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes flash-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.flash-toast.is-hiding {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .22s, transform .22s;
}
@media (max-width: 900px) {
  .flash-toast-region { top: 70px; }
}
@media (max-width: 640px) {
  .flash-toast-region { top: 70px; right: 12px; width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  .flash-toast { animation: none; }
  .flash-toast.is-hiding { transition: none; }
}

/* ── PANELS ─────────────────────────────────────────────── */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .22s ease, border-color .22s ease;
}
.panel + .panel { margin-top: 18px }

/* Séparateur de section dans un panel */
.panel-section {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* Panel header ligne */
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.panel-head h1, .panel-head h2 { margin-bottom: 2px }
.panel-head--stack-mobile { align-items: center }
.panel-head--no-border { border-bottom: none; padding-bottom: 0; margin-bottom: 0 }

/* ── GRID ───────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px }
.col-4  { grid-column: span 4 }
.col-6  { grid-column: span 6 }
.col-8  { grid-column: span 8 }
.col-12 { grid-column: span 12 }
.grid-stretch > [class*="col-"] { display: flex }
.grid-stretch > [class*="col-"] > .panel { width: 100%; height: 100% }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .14s ease,
              border-color .14s ease,
              box-shadow .14s ease,
              transform .09s ease,
              color .14s ease;
  line-height: 1.4;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:hover {
  background: var(--card2);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.btn:active:not([disabled]) {
  transform: translateY(0) scale(.97) !important;
  box-shadow: none !important;
  transition-duration: .06s !important;
}
.btn.primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}
html.theme-dark .btn.primary {
  background: var(--accent);
  color: #111827;
}
.btn.primary:hover {
  background: var(--primary-hover);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(31,41,55,.22);
}
html.theme-dark .btn.primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px rgba(245,158,11,.28);
}
.btn.danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}
.btn.danger:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 16px rgba(220,38,38,.2);
  border-color: transparent;
}
.btn.sm, .btn.btn-sm {
  padding: 5px 10px;
  border-radius: var(--radius-xs);
  font-size: .82rem;
}
.btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-circle-primary {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .1s, box-shadow .1s, background .12s;
}
html.theme-dark .btn-circle-primary { background: var(--accent); color: #111827 }
.btn-circle-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  color: #fff;
  text-decoration: none;
}

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid #6b7280;
  background: #6b7280;
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: .01em;
}
.badge.good { border-color: var(--success); background: var(--success) }
.badge.warn { border-color: var(--warning); background: var(--warning) }
.badge.bad  { border-color: var(--danger);  background: var(--danger) }
.badge.info { border-color: var(--info);    background: var(--info) }

/* ── MUTED ──────────────────────────────────────────────── */
.muted { color: var(--muted); font-size: .88rem }

/* ── FORMS ──────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--text);
  font-size: .875rem;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) {
  border-color: var(--border-strong);
  background: var(--card2);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
  background: var(--card);
}
textarea { min-height: 110px; resize: vertical }
html.theme-dark input,
html.theme-dark select,
html.theme-dark textarea {
  background: rgba(255,255,255,.04);
  border-color: var(--border);
  color: var(--text);
}

.form-row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px }
.form-row .field { grid-column: span 6 }
.form-row .field.full { grid-column: span 12 }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; color: var(--text) }
.help { color: var(--muted); font-size: .82rem; margin-top: 5px }

/* ── Utility layout ────────────────────────────────────── */
.stack-xs { margin-top: 6px }
.stack-sm { margin-top: 10px }
.stack-md { margin-top: 12px }
.stack-lg { margin-top: 16px }
.stack-xl { margin-top: 22px }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.section-head-start { align-items: flex-start }
.inline-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-actions-end {
  justify-content: flex-end;
}
.soft-note {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card2);
  color: var(--muted);
}
.text-strong { font-weight: 700 }
.hidden { display: none }

/* ── TABLES ─────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  display: table;
}
.table th, .table td {
  padding: 12px 15px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
  transition: background .1s;
}
.table thead th {
  font-size: .71rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--card2);
  border-bottom: 2px solid var(--border-strong);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
  user-select: none;
}

/* Zébrures */
.table tbody tr:nth-child(even) td { background: var(--card2) }
.table tbody tr:nth-child(odd)  td { background: var(--card) }
.table tbody tr:hover           td { background: var(--accent-weak) !important }
html.theme-dark .table tbody tr:nth-child(even) td { background: rgba(255,255,255,.022) }
html.theme-dark .table tbody tr:nth-child(odd)  td { background: transparent }
html.theme-dark .table tbody tr:hover           td { background: var(--accent-weak) !important }

/* Table dans une card avec bords arrondis */
.table-wrap {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.table-wrap .table { border: none }
.table-wrap .table th { border-left: none; border-right: none }
.table-wrap .table td { border-left: none; border-right: none }
.table-wrap .table thead th:first-child { border-top-left-radius: var(--radius-lg) }
.table-wrap .table thead th:last-child  { border-top-right-radius: var(--radius-lg) }
.table-wrap .table tbody tr:last-child td { border-bottom: none }

/* Styles variants */
.table.table-compact th, .table.table-compact td { padding: 7px 12px; font-size: .84rem }
.table-sub th, .table-sub td { white-space: normal; word-break: break-word }

/* Table sans fond panel — utilisée en standalone dans .panel */
.panel > .table-wrap { margin-top: 4px }
.panel > .table      { margin-top: 4px }

/* ── COMMENTS ───────────────────────────────────────────── */
.comment {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: var(--card);
}
.comment + .comment { margin-top: 10px }
.comment-meta {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  color: var(--muted);
  font-size: .84rem;
  margin-bottom: 8px;
}

/* ── ATTACHMENTS ────────────────────────────────────────── */
.attachments { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px }
.thumb {
  display: inline-block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-xs);
}
.thumb img { display: block; max-width: 220px; height: auto }

/* ── HELPERS INLINE ─────────────────────────────────────── */
.inline-form  { display: inline-flex; margin: 0 }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap }
.input-with-action { display: flex; gap: 10px; align-items: center }
.input-with-action select, .input-with-action input { flex: 1 1 auto }
.filter-actions .btn { width: 120px; justify-content: center }
.panel-actions { display: flex; justify-content: flex-end; gap: 10px; grid-column: span 12 }

/* ── DASHBOARD STAT CARDS ───────────────────────────────── */
.dashboard-stat-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
}
.dashboard-stat-card .stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  margin-top: 8px;
  line-height: 1;
}

/* ── AUTH / LOGIN ───────────────────────────────────────── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}
.auth-card-outer {
  width: 100%;
  max-width: 400px;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 26px;
  text-decoration: none;
}
.auth-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f59e0b, #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: .95rem;
  color: #fff;
  box-shadow: 0 4px 14px rgba(245,158,11,.3);
}
.auth-logo-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 30px 28px;
  box-shadow: var(--shadow-md);
}
.auth-card h1 {
  font-size: 1.35rem;
  margin-bottom: 4px;
  text-align: center;
}
.auth-card .auth-sub {
  color: var(--muted);
  font-size: .875rem;
  text-align: center;
  margin-bottom: 22px;
}
.auth-card .form-row { gap: 12px }
.auth-card .field { grid-column: span 12 }
.auth-card .btn {
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  justify-content: center;
}
.auth-footer {
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
}

/* legacy auth */
.auth-layout {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 16px;
  min-height: calc(100vh - 90px);
  align-items: stretch;
  margin-top: 18px;
}
.auth-side {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(245,158,11,.06), rgba(31,41,55,.04), rgba(249,250,251,.9));
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
html.theme-dark .auth-side {
  background: linear-gradient(135deg, rgba(245,158,11,.08), rgba(13,17,23,.7));
}
.auth-side-inner { padding: 28px }
.auth-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  margin-bottom: 14px;
}
.auth-list { margin: 14px 0 0; padding-left: 18px; color: var(--muted) }

/* ── ADMIN LAYOUT ───────────────────────────────────────── */
.admin-app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
  gap: 0;
  min-height: calc(100vh - var(--topbar-height));
}
.admin-sidebar {
  position: sticky;
  top: var(--topbar-height);
  align-self: start;
  min-height: calc(100vh - var(--topbar-height));
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: 18px 14px;
}
.admin-main { min-width: 0; padding: 0 20px }
.admin-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.admin-sidebar-toggle { min-width: 38px; padding: 7px 10px }
.admin-menu { display: flex; flex-direction: column; gap: 6px }
.admin-menu-group-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 10px 4px 2px;
}
.admin-menu-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--card2);
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.admin-menu-link:hover {
  text-decoration: none;
  border-color: rgba(245,158,11,.3);
  background: var(--card);
}
.admin-menu-link.active {
  background: var(--accent-weak);
  border-color: rgba(245,158,11,.3);
}
.admin-menu-link span { font-weight: 600; font-size: .88rem }
.admin-menu-link small { color: var(--muted); font-size: .8rem }
.admin-sidebar-stats { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 14px }
.admin-stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--card);
}
.admin-stat-card strong { display: block; font-size: 1.15rem; font-weight: 800 }
.admin-stat-card span { color: var(--muted); font-size: .84rem }
.admin-content-panel { padding: 20px; margin-left: 0 }
.admin-head-actions { display: flex; gap: 10px; flex-wrap: wrap }
.admin-form-grid { display: grid; grid-template-columns: repeat(12,1fr); gap: 16px }
.admin-form-grid .field { grid-column: span 12 }

/* Admin expand rows */
.admin-parent-row { cursor: pointer }
.admin-parent-row td { transition: background .1s }
.admin-parent-row.is-open td { background: var(--accent-weak) !important }
.admin-client-cell { display: flex; align-items: center; gap: 10px }
.admin-row-chevron {
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .12s;
  margin-left: 2px;
}
.admin-parent-row.is-open .admin-row-chevron { transform: rotate(45deg) }
.admin-child-row td { background: var(--card2); padding: 0 }
.admin-child-panel { padding: 16px }

/* Admin user table widths */
.admin-users-table .table { min-width: 860px }
.admin-users-table .table th:nth-child(1),
.admin-users-table .table td:nth-child(1) { width: 20% }
.admin-users-table .table th:nth-child(2),
.admin-users-table .table td:nth-child(2) { width: 28% }
.admin-users-table .table th:nth-child(3),
.admin-users-table .table td:nth-child(3) { width: 16% }
.admin-users-table .table th:nth-child(4),
.admin-users-table .table td:nth-child(4) { width: 10% }
.admin-users-table .table th:nth-child(5),
.admin-users-table .table td:nth-child(5) { width: 26% }
.admin-users-table--client .table { min-width: 1100px }

/* ── Human-readable status administration ───────────────── */
.status-admin-shell {
  display: grid;
  gap: 16px;
}
.status-admin-hero,
.status-create-panel,
.status-type-panel,
.status-admin-guide {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.status-admin-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 24px;
}
.status-admin-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(184,107,53,.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(184,107,53,.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(90deg, rgba(0,0,0,.42), transparent 62%);
}
.status-admin-hero > * {
  position: relative;
}
.status-admin-hero h1 {
  margin: 8px 0;
  font-size: 1.22rem;
  line-height: 1.3;
  text-wrap: normal;
}
.status-admin-hero p {
  max-width: 72ch;
  color: var(--muted);
}
.status-admin-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
}
.status-admin-summary div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}
.status-admin-summary span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
}
.status-admin-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.status-admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.status-admin-guide,
.status-create-panel,
.status-type-panel {
  padding: 18px;
}
.status-admin-guide {
  position: sticky;
  top: calc(var(--topbar-height) + 18px);
}
.status-admin-guide h2,
.status-create-panel h2,
.status-type-panel h2 {
  font-size: 1rem;
}
.status-guide-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.status-guide-list div {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.status-guide-list div:first-child {
  padding-top: 0;
  border-top: 0;
}
.status-guide-list strong {
  display: block;
  font-size: .9rem;
}
.status-guide-list span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}
.status-form {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.status-form .field {
  grid-column: span 6;
}
.status-form .field.full {
  grid-column: 1 / -1;
}
.status-color-field input[type="color"] {
  min-height: 42px;
  padding: 5px;
}
.status-checkset {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.status-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
  cursor: pointer;
}
.status-check input {
  margin-top: 3px;
}
.status-check strong {
  display: block;
  font-size: .88rem;
}
.status-check small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}
.status-type-panel {
  display: grid;
  gap: 14px;
}
.status-type-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.status-type-metrics span,
.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card2);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
}
.status-card-list {
  display: grid;
  gap: 10px;
}
.status-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.status-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.status-card.is-muted {
  opacity: .72;
}
.status-flow-number {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: var(--card2);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.status-card-main {
  min-width: 0;
  display: grid;
  gap: 12px;
}
.status-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.status-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}
.status-title-wrap h3 {
  margin: 0;
  font-size: 1.05rem;
}
.status-color-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-top: 4px;
  border-radius: 4px;
  background: var(--status-color, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-color, var(--accent)) 18%, transparent);
}
.status-ref {
  margin-top: 3px;
  color: var(--muted);
  font-size: .8rem;
}
.status-ref code {
  font-size: .78rem;
}
.status-badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.status-pill.default {
  border-color: var(--accent);
  background: var(--accent-weak);
  color: var(--accent-hover);
}
.status-pill.active {
  border-color: color-mix(in srgb, var(--success) 34%, var(--border));
  background: var(--success-weak);
  color: var(--success);
}
.status-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.status-rule {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
}
.status-rule span {
  display: block;
  color: var(--muted);
  font-size: .74rem;
}
.status-rule strong {
  display: block;
  margin-top: 3px;
  font-size: .92rem;
}
.status-rule small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}
.status-rule.locked {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
  background: var(--danger-weak);
}
.status-rule.team {
  border-color: color-mix(in srgb, var(--info) 28%, var(--border));
  background: var(--info-weak);
}
.status-rule.open {
  border-color: color-mix(in srgb, var(--success) 24%, var(--border));
  background: var(--success-weak);
}
.status-edit-details {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.status-edit-details summary {
  list-style: none;
  cursor: pointer;
}
.status-edit-details summary::-webkit-details-marker {
  display: none;
}
.status-form-edit {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
}

/* ── DARK MODE INLINE OVERRIDES ─────────────────────────── */
html.theme-dark [style*="background:#fff"],
html.theme-dark [style*="background: #fff"],
html.theme-dark [style*="background:#ffffff"],
html.theme-dark [style*="background: #ffffff"],
html.theme-dark [style*="background:#f8fafc"],
html.theme-dark [style*="background: #f8fafc"],
html.theme-dark [style*="background:#fbfdff"],
html.theme-dark [style*="background: #fbfdff"],
html.theme-dark [style*="background:#fbfcff"],
html.theme-dark [style*="background: #fbfcff"] {
  background: var(--card2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
html.theme-dark [style*="color:#0f172a"],
html.theme-dark [style*="color: #0f172a"],
html.theme-dark [style*="color:#111827"],
html.theme-dark [style*="color: #111827"] { color: var(--text) !important }
html.theme-dark [style*="border:1px solid #e5e7eb"],
html.theme-dark [style*="border: 1px solid #e5e7eb"] { border-color: var(--border) !important }
html.theme-dark .flash,
html.theme-dark .comment,
html.theme-dark .thumb,
html.theme-dark .admin-stat-card {
  background: var(--card2) !important;
  border-color: var(--border) !important;
  color: var(--text);
}
html.theme-dark .admin-menu-link:hover { background: var(--card) !important }
html.theme-dark iframe { background: var(--card2) !important }

/* ── MISC LEGACY ────────────────────────────────────────── */
.nav-user-summary { max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }

/* ── MEDIA QUERIES ──────────────────────────────────────── */
@media (max-width: 1060px) {
  .status-admin-layout {
    grid-template-columns: 1fr;
  }
  .status-admin-guide {
    position: static;
  }
}
@media (max-width: 760px) {
  .status-admin-hero {
    display: grid;
    padding: 16px;
  }
  .status-admin-summary,
  .status-checkset,
  .status-rule-grid {
    grid-template-columns: 1fr;
  }
  .status-form .field {
    grid-column: 1 / -1;
  }
  .status-card {
    grid-template-columns: 1fr;
  }
  .status-flow-number {
    width: fit-content;
    padding: 0 10px;
  }
  .status-badge-row {
    justify-content: flex-start;
  }
}

@media (max-width: 1100px) {
  .admin-app { grid-template-columns: 1fr }
  .admin-sidebar { position: static; min-height: auto; border-radius: 0 }
  .admin-main { padding: 16px }
}

@media (max-width: 900px) {
  body.has-leftmenu { padding-left: 0 !important }

  .platform-leftmenu {
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    width: var(--sidebar-width) !important;
    transition: transform .22s ease, opacity .22s ease, visibility 0s linear .22s;
  }
  body.leftmenu-open .platform-leftmenu {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform .22s ease, opacity .22s ease, visibility 0s linear 0s;
  }

  /* Reset collapsed overrides */
  body.leftmenu-collapsed .platform-leftmenu-link {
    justify-content: flex-start; gap: 10px; padding: 8px 10px;
  }
  body.leftmenu-collapsed .sidebar-link-label,
  body.leftmenu-collapsed .sidebar-link-badge { opacity: 1; width: auto; overflow: visible }
  body.leftmenu-collapsed .sidebar-brand-name { opacity: 1; width: auto; overflow: visible }
  body.leftmenu-collapsed .sidebar-group-label {
    opacity: 1; height: auto; padding: 6px 10px 3px; overflow: visible;
  }
  body.leftmenu-collapsed .sidebar-user { justify-content: flex-start; padding: 7px 10px }
  body.leftmenu-collapsed .sidebar-user-info { opacity: 1; width: auto; overflow: visible }
  body.leftmenu-collapsed .sidebar-theme-btn {
    justify-content: flex-start; padding: 8px 10px;
  }
  body.leftmenu-collapsed .sidebar-theme-btn .sidebar-link-label { opacity: 1; width: auto }
  body.leftmenu-collapsed .sidebar-collapse-btn { transform: none }

  .col-4, .col-6, .col-8 { grid-column: span 12 }
  .container { padding: 16px }
  .form-row .field { grid-column: span 12 }
  .table { min-width: 680px }
  .panel-head,
  .panel-head--stack-mobile { flex-direction: column; align-items: flex-start }
  .auth-layout { grid-template-columns: 1fr; min-height: auto }
  .main-fullwidth-flash { margin: 14px 16px }
  .page-back-wrap-full { margin: 0 16px 14px }
}

/* ═══════════════════════════════════════════════════════
   LIST SIMPLE — Cartes épurées pour listes (specs, devis, clients…)
   ═══════════════════════════════════════════════════════ */

.list-simple {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Un item de liste = une ligne compacte et aérée */
.list-simple .list-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  cursor: pointer;
}

.list-simple .list-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(245,158,11,.12);
  transform: translateY(-1px);
}

/* Colonne 1 : avatar ou icône */
.list-item .list-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #1f2937;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}
.list-item .list-avatar.list-avatar-blue {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff;
}
.list-item .list-avatar.list-avatar-purple {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff;
}
.list-item .list-avatar.list-avatar-gray {
  background: linear-gradient(135deg, #9ca3af, #6b7280); color: #fff;
}
.list-item .list-avatar i { font-size: 1.05rem; }

/* Colonne 2 : contenu principal */
.list-item .list-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.list-item .list-title {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .list-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: .78rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.list-item .list-meta .dot { opacity: .5; }
.list-item .list-meta a { color: inherit; text-decoration: none; }
.list-item .list-meta a:hover { color: var(--accent); }

/* Colonne 3 : badges/infos secondaires */
.list-item .list-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Colonne 4 : menu actions */
.list-item .list-actions {
  position: relative;
  flex-shrink: 0;
}
.list-item .list-actions-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.list-item .list-actions-btn:hover {
  background: var(--accent-weak);
  color: var(--accent);
  border-color: var(--border);
}
.list-item .list-actions-btn i { font-size: 1rem; }

/* Menu dropdown */
.list-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  padding: 6px;
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.list-actions-menu.is-floating {
  position: fixed;
  right: auto;
  z-index: 2200;
  width: min(300px, calc(100vw - 16px));
  box-sizing: border-box;
  max-height: min(70vh, 360px);
  overflow-y: auto;
}
.list-actions-menu.open { display: flex; }
.list-actions-menu button,
.list-actions-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  transition: background .12s;
  font-family: inherit;
}
.list-actions-menu button:hover,
.list-actions-menu a:hover {
  background: var(--card2);
}
.list-actions-menu button.danger:hover,
.list-actions-menu a.danger:hover {
  background: var(--danger-weak);
  color: var(--danger);
}
.list-actions-menu i {
  width: 16px;
  text-align: center;
  font-size: .9rem;
  color: var(--muted);
}
.list-actions-menu button.danger i,
.list-actions-menu a.danger i { color: var(--danger); }
.list-actions-menu .menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Badge wrapper pour list-side */
.list-side .badge-soft {
  padding: 3px 9px;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--card2);
  color: var(--muted);
  white-space: nowrap;
}
.list-side .date-soft {
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Empty state */
.list-simple-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.list-simple-empty i { font-size: 2.2rem; display: block; margin-bottom: 10px; opacity: .35; }

/* Compact variant (for nested lists) */
.list-simple.compact .list-item {
  padding: 10px 14px;
  gap: 10px;
}
.list-simple.compact .list-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: .78rem;
}

/* Mobile : stack side + actions */
@media (max-width: 640px) {
  .list-simple .list-item {
    grid-template-columns: auto 1fr auto;
    padding: 12px;
  }
  .list-item .list-side { display: none; }
  .list-item .list-meta { font-size: .75rem; }
}

/* ── Project workflow ───────────────────────────────────── */
.project-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr);
  gap: 18px;
  align-items: stretch;
}
.project-hero-main,
.project-next-action,
.project-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.project-hero-main {
  position: relative;
  overflow: hidden;
  padding: 24px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}
.project-hero-main::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(184,107,53,.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(184,107,53,.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(90deg, rgba(0,0,0,.4), transparent 58%);
}
.project-hero-main > * { position: relative }
.project-eyebrow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: .82rem;
}
.project-hero-main h1 {
  max-width: 880px;
  font-size: 1.26rem;
  line-height: 1.3;
  letter-spacing: -.01em;
  margin: 8px 0 10px;
  text-wrap: normal;
  overflow-wrap: anywhere;
}
.project-summary {
  max-width: 76ch;
  color: var(--muted);
  font-size: 1rem;
}
.project-meta-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}
.project-meta-item {
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--card2);
  border: 1px solid var(--border);
}
.project-meta-item span {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  margin-bottom: 3px;
}
.project-meta-item strong {
  font-size: .9rem;
  font-weight: 650;
}
.project-next-action {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 3px solid var(--accent);
}
.project-next-action h2,
.project-section h2 {
  font-size: 1rem;
  letter-spacing: 0;
}
.project-actions-stack {
  display: grid;
  gap: 10px;
}
.project-action-form {
  display: grid;
  gap: 8px;
}
.project-action-form textarea {
  min-height: 84px;
}
.project-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 16px;
  margin-top: 16px;
}
.project-section {
  padding: 18px;
}
.project-section + .project-section {
  margin-top: 16px;
}
.project-brief-list {
  display: grid;
  gap: 12px;
}
.project-brief-item {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.project-brief-item:first-child {
  border-top: 0;
  padding-top: 0;
}
.project-brief-item h3 {
  margin-bottom: 4px;
  font-size: .85rem;
  color: var(--muted);
  font-weight: 650;
}
.project-brief-item div {
  white-space: pre-wrap;
}
.project-meeting-icon {
  background: var(--accent-weak);
  color: var(--accent-hover);
}
.project-timeline {
  display: grid;
  gap: 12px;
}
.project-message-list,
.project-file-list,
.project-point-list {
  display: grid;
  gap: 10px;
}
.project-message {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--card2);
}
.project-message:hover,
.project-file-row:hover,
.project-point-row:hover,
.project-inbox-card:hover {
  box-shadow: var(--shadow-sm);
}
.project-message-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: .78rem;
  margin-bottom: 6px;
}
.project-message-body {
  white-space: pre-wrap;
  line-height: 1.5;
}
.project-file-row,
.project-point-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.project-file-row:hover,
.project-point-row:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.project-file-icon,
.project-point-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--accent-weak);
  color: var(--accent);
}
.project-file-name,
.project-point-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}
.project-file-meta,
.project-point-meta {
  color: var(--muted);
  font-size: .78rem;
  margin-top: 2px;
}
.project-stat-line {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.project-stat-line div {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
}
.project-stat-line strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.project-stat-line span {
  display: block;
  color: var(--muted);
  font-size: .76rem;
  margin-top: 4px;
}
.project-event {
  position: relative;
  padding-left: 18px;
}
.project-event::before {
  content: "";
  position: absolute;
  left: 0;
  top: .45rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.project-event-title {
  font-weight: 650;
}
.project-event-meta {
  color: var(--muted);
  font-size: .78rem;
  margin-top: 2px;
}
.project-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.project-status-new { background: #f4e4d8; color: #7a3d16; border-color: #e8c5ad; }
.project-status-approved { background: #e5f0ec; color: #1f5b4d; border-color: #bfd8d0; }
.project-status-meeting { background: #e8eef6; color: #2f5f88; border-color: #c7d7ea; }
.project-status-quote { background: #f2ead7; color: #7a5415; border-color: #dfc991; }
.project-status-progress { background: #e4eef7; color: #21506f; border-color: #bed2e2; }
.project-status-waiting { background: #fff3d7; color: #7a5415; border-color: #ead193; }
.project-status-ready { background: #ece7f5; color: #4d3a77; border-color: #d2c5eb; }
.project-status-closed { background: #e5f0ec; color: #237a57; border-color: #c5ded4; }
.project-status-refused { background: #f7e3e0; color: #9b2c20; border-color: #e8b9b3; }
.project-form-shell {
  max-width: 980px;
  margin: 0 auto;
}
.project-form-intro {
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}
.project-form-intro h1 {
  font-size: 1.22rem;
  line-height: 1.3;
  letter-spacing: -.01em;
  text-wrap: normal;
}
.project-form-grid {
  display: grid;
  gap: 14px;
}
.project-inbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.project-inbox-card {
  display: block;
  padding: 14px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.project-inbox-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.project-inbox-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 980px) {
  .project-hero,
  .project-grid {
    grid-template-columns: 1fr;
  }
  .project-meta-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .project-stat-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .project-hero-main,
  .project-next-action,
  .project-section,
  .project-form-intro {
    padding: 14px;
  }
  .project-meta-strip {
    grid-template-columns: 1fr;
  }
  .project-file-row,
  .project-point-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .project-file-row .btn,
  .project-point-row .btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* ── Point validation workbench ─────────────────────────── */
.point-workbench {
  display: grid;
  gap: 14px;
}
.point-shell {
  padding: 18px;
}
.point-hero {
  display: grid;
  gap: 14px;
}
.point-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.point-heading h1 {
  margin: 6px 0 4px;
  font-size: 1.22rem;
  line-height: 1.3;
  letter-spacing: -.01em;
  text-wrap: normal;
  overflow-wrap: anywhere;
}
.point-actions,
.point-inline-form,
.checklist-header {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.point-state-form {
  margin: 0;
}
.point-state-picker {
  position: relative;
  display: inline-flex;
}
.point-state-picker select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.point-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.point-subcard {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card2);
}
.point-subcard h3 {
  margin: 0 0 8px;
  font-size: .95rem;
}
.point-subtitle {
  margin-bottom: 8px;
  font-size: .95rem;
}
.point-inline-form-nowrap {
  flex-wrap: nowrap;
}
.point-assignees {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}
.checklist-header {
  justify-content: space-between;
  margin-bottom: 6px;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checklist-label.done {
  text-decoration: line-through;
  color: var(--muted);
}
.point-section,
.point-content-panel,
.point-validation-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.point-validation-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 12px;
}
.point-validation-copy,
.point-request-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card2);
}
.point-validation-actions,
.point-request-list,
.checklist-list,
.point-comment-list {
  display: grid;
  gap: 10px;
}
.point-content,
.point-comment-body,
.point-request-body,
.point-request-response {
  white-space: pre-wrap;
  line-height: 1.5;
}
.point-request-body {
  margin-top: 8px;
}
.point-request-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.point-request-title {
  font-weight: 700;
}
.point-request-response {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 8px;
}
.point-request-files {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.point-request-files-title {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
}
.point-request-file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.point-request-file-row:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transform: translateY(-1px);
}
.point-request-file-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--accent-weak);
  color: var(--accent);
}
.point-request-file-name {
  display: block;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.point-request-file-meta {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  margin-top: 2px;
}
.point-file-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-top: 10px;
}
.point-file {
  width: 92px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.point-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 92px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.point-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.point-thumb-file,
.point-file-icon {
  font-size: 1.6rem;
}
.point-file-name {
  font-size: .82rem;
  line-height: 1.25;
  word-break: break-word;
}
.point-composer {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.portal-file-list { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.portal-file-link {
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-width:0;
  max-width:100%;
  min-height:36px;
  padding:7px 10px;
  border:1px solid var(--border);
  border-radius:9px;
  background:var(--card);
  color:var(--text);
  font-size:.82rem;
  font-weight:650;
  text-decoration:none;
  transition:background-color 140ms ease-out,color 140ms ease-out,border-color 140ms ease-out;
}
.portal-file-link:hover { border-color:color-mix(in srgb,var(--accent) 42%,var(--border)); background:var(--accent-weak); color:var(--accent); }
.portal-file-link:active { transform:scale(.985); }
.portal-file-link span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.portal-file-link small { flex:0 0 auto; color:var(--muted); font-size:.72rem; font-weight:600; }
.portal-file-link i { flex:0 0 auto; color:var(--accent); }
.portal-file-link[data-file-preview] { cursor:zoom-in; }
.file-preview-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 12000;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2vw, 24px);
  background: rgba(8, 12, 20, .76);
  opacity: 0;
  transition: opacity 180ms ease-out;
  backdrop-filter: blur(12px) saturate(120%);
}
.file-preview-modal.is-open {
  display: flex;
  opacity: 1;
}
.file-preview-shell {
  width: min(1240px, 100%);
  height: min(92dvh, 960px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 72%, transparent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .38);
  transform: scale(.985);
  transition: transform 180ms ease-out;
}
.file-preview-modal.is-open .file-preview-shell { transform: scale(1); }
.file-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--border);
}
.file-preview-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: .95rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-preview-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.file-preview-action {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
}
.file-preview-action:hover { border-color: color-mix(in srgb,var(--accent) 42%,var(--border)); background: var(--accent-weak); color: var(--accent); }
.file-preview-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card2);
  color: var(--text);
  cursor: pointer;
  transition: background-color 140ms ease-out, transform 100ms ease-out;
}
.file-preview-close:hover { background: var(--accent-weak); color: var(--accent); }
.file-preview-close:active { transform: scale(.94); }
.file-preview-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 14px;
  background: color-mix(in srgb, var(--bg) 82%, #000 18%);
}
.file-preview-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.file-preview-pdf {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.file-preview-image[hidden],
.file-preview-pdf[hidden] { display: none !important; }
.file-preview-modal.is-pdf .file-preview-body { padding: 0; background: #fff; }
.file-preview-status {
  position: absolute;
  z-index: 1;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-size: .9rem;
  text-align: center;
}
body.file-preview-open { overflow: hidden; }
@media (max-width: 640px) {
  .file-preview-modal { padding: 0; }
  .file-preview-shell { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .file-preview-head { gap: 8px; padding-left: 12px; }
  .file-preview-action { width: 44px; padding: 0; }
  .file-preview-action span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .file-preview-body { padding: 8px; }
  .file-preview-modal.is-pdf .file-preview-body { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .file-preview-modal, .file-preview-shell { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .file-preview-modal { background: rgba(8, 12, 20, .92); backdrop-filter: none; }
  .file-preview-shell { background: var(--card); }
}
@media (max-width: 840px) {
  .point-validation-panel {
    grid-template-columns: 1fr;
  }
}

/* Dolibarr connection settings */
.dolibarr-settings-page .admin-content-panel {
  max-width: 1120px;
  margin-inline: auto;
}
.dolibarr-settings-heading,
.dolibarr-section-heading,
.dolibarr-settings-actions,
.dolibarr-flow-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.dolibarr-settings-heading {
  align-items: flex-start;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.dolibarr-settings-heading h1 { margin: 3px 0 5px; }
.dolibarr-settings-heading p { max-width: 66ch; margin: 0; }
.dolibarr-settings-kicker,
.dolibarr-section-index {
  color: var(--accent-hover);
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.dolibarr-connection-flow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}
.dolibarr-flow-step {
  justify-content: flex-start;
  min-width: 0;
  padding: 18px 20px 18px 0;
}
.dolibarr-flow-step + .dolibarr-flow-step {
  padding-left: 20px;
  border-left: 1px solid var(--border);
}
.dolibarr-flow-mark {
  display: grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--accent-hover);
  font-size: .72rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.dolibarr-flow-step > div { display: grid; gap: 3px; min-width: 0; }
.dolibarr-flow-step strong { font-size: .9rem; }
.dolibarr-flow-step > div span { color: var(--muted); font-size: .79rem; line-height: 1.4; }
.dolibarr-state {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
}
.dolibarr-state.is-ready { color: var(--success); background: var(--success-weak); }
.dolibarr-state.is-pending { color: var(--muted); background: var(--card2); }
.dolibarr-settings-form { display: grid; }
.dolibarr-settings-section { padding: 25px 0; border-bottom: 1px solid var(--border); }
.dolibarr-section-heading { align-items: flex-start; margin-bottom: 19px; }
.dolibarr-section-heading h2 { margin: 3px 0 4px; font-size: 1.16rem; }
.dolibarr-section-heading p { margin: 0; max-width: 72ch; font-size: .88rem; }
.dolibarr-section-icon {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--accent-hover);
  background: var(--accent-weak);
}
.dolibarr-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px 20px;
  max-width: 850px;
}
.dolibarr-fields-grid .field { min-width: 0; }
.dolibarr-fields-grid input { width: 100%; }
.dolibarr-fields-grid .dolibarr-field-narrow { max-width: 180px; }
.dolibarr-security-note {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  max-width: 850px;
  margin-top: 20px;
  padding: 12px 14px;
  border-left: 3px solid var(--info);
  background: var(--info-weak);
  color: var(--text);
}
.dolibarr-security-note > i { margin-top: 2px; color: var(--info); }
.dolibarr-security-note p { margin: 0; font-size: .82rem; line-height: 1.55; }
.dolibarr-api-fields { max-width: 100%; }
.dolibarr-api-help { margin-top: 12px; }
.dolibarr-settings-actions {
  flex-wrap: wrap;
  padding-top: 20px;
}
.dolibarr-settings-actions .inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dolibarr-storage-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.dolibarr-storage-status i { color: var(--success); }
.dossier-dolibarr-sync {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--border);
}
.dossier-dolibarr-sync__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.dossier-dolibarr-sync__heading > div { display: grid; gap: 3px; }
.dossier-dolibarr-sync__heading span:not(.badge) { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.dossier-dolibarr-sync__error { margin: 0; color: var(--danger); font-size: .84rem; }
.dossier-dolibarr-sync .inline-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dossier-dolibarr-sync .inline-actions form { margin: 0; }
.dossier-sync-review summary { cursor: pointer; color: var(--text); font-weight: 700; font-size: .84rem; }
.dossier-sync-review form { display: grid; gap: 8px; max-width: 520px; margin-top: 10px; }
.dossier-sync-review input { min-width: 180px; }
@media (max-width: 900px) {
  .dolibarr-connection-flow { grid-template-columns: 1fr; }
  .dolibarr-flow-step { padding-right: 0; }
  .dolibarr-flow-step + .dolibarr-flow-step { padding-left: 0; border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 620px) {
  .dossier-dolibarr-sync__heading { align-items: stretch; flex-direction: column; }
  .dossier-dolibarr-sync__heading .badge { align-self: flex-start; }
  .dossier-sync-review .inline-actions { align-items: stretch; flex-direction: column; }
  .dossier-sync-review input, .dossier-sync-review .btn { width: 100%; }
  .dolibarr-settings-heading,
  .dolibarr-settings-actions { align-items: stretch; flex-direction: column; }
  .dolibarr-settings-heading > .btn { align-self: flex-start; }
  .dolibarr-fields-grid { grid-template-columns: 1fr; }
  .dolibarr-fields-grid .dolibarr-field-narrow { max-width: none; }
  .dolibarr-flow-step { flex-wrap: wrap; }
  .dolibarr-state { margin-left: 47px; }
  .dolibarr-settings-actions .inline-actions { flex-direction: column; }
  .dolibarr-settings-actions .inline-actions .btn { width: 100%; justify-content: center; }
}

.rich-text-source {
  display: none !important;
}

.rich-text-editor {
  width: 100%;
  border: 1px solid var(--border, #dbe3ef);
  border-radius: 16px;
  background: var(--surface, #fff);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .06);
  overflow: hidden;
}

.rich-text-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .55) transparent;
  white-space: nowrap;
  padding: 8px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: linear-gradient(180deg, rgba(248, 250, 252, .98), rgba(241, 245, 249, .92));
}

.rich-text-toolbar::-webkit-scrollbar {
  height: 5px;
}

.rich-text-toolbar::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(148, 163, 184, .55);
}

.rich-text-btn,
.rich-text-select {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid rgba(148, 163, 184, .42);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
}

.rich-text-btn {
  padding: 0 10px;
  cursor: pointer;
}

.rich-text-select {
  padding: 0 28px 0 10px;
}

.rich-text-btn:hover,
.rich-text-select:hover,
.rich-text-btn:focus-visible,
.rich-text-select:focus-visible {
  border-color: #2563eb;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}

.rich-text-editor--invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .14);
}

.rich-text-surface {
  min-height: 150px;
  padding: 14px 16px;
  color: #0f172a;
  line-height: 1.62;
  overflow: auto;
  outline: none;
}

.rich-text-editor--compact .rich-text-surface {
  min-height: 96px;
}

.rich-text-surface:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
}

.rich-text-surface p {
  margin: 0 0 .75em;
}

.rich-text-surface p:last-child,
.workspace-rich-text p:last-child,
.ticket-detail-message p:last-child,
.point-content p:last-child,
.point-comment-body p:last-child,
.dossier-rich-text p:last-child {
  margin-bottom: 0;
}

.workspace-rich-text,
.ticket-detail-message,
.point-content,
.point-comment-body,
.dossier-rich-text {
  line-height: 1.62;
}

.workspace-rich-text p,
.ticket-detail-message p,
.point-content p,
.point-comment-body p,
.dossier-rich-text p {
  margin: 0 0 .75em;
}

.workspace-rich-text ul,
.workspace-rich-text ol,
.ticket-detail-message ul,
.ticket-detail-message ol,
.point-content ul,
.point-content ol,
.point-comment-body ul,
.point-comment-body ol,
.dossier-rich-text ul,
.dossier-rich-text ol,
.rich-text-surface ul,
.rich-text-surface ol {
  margin: .45em 0 .85em 1.25em;
  padding-left: 1.05em;
}

.workspace-rich-text li,
.ticket-detail-message li,
.point-content li,
.point-comment-body li,
.dossier-rich-text li,
.rich-text-surface li {
  margin: .25em 0;
}

.theme-dark .rich-text-editor {
  background: #0f172a;
  border-color: rgba(148, 163, 184, .24);
  box-shadow: none;
}

.theme-dark .rich-text-toolbar {
  background: rgba(15, 23, 42, .95);
  border-color: rgba(148, 163, 184, .18);
}

.theme-dark .rich-text-btn,
.theme-dark .rich-text-select {
  background: #111827;
  color: #e5e7eb;
  border-color: rgba(148, 163, 184, .25);
}

.theme-dark .rich-text-surface {
  color: #e5e7eb;
}
