:root {
  --ui-control-primary: var(--brand-navy, #1b2a4a);
  --ui-control-primary-hover: #293f61;
  --ui-control-primary-border: var(--brand-navy, #1b2a4a);
  --ui-control-success: #176344;
  --ui-control-success-hover: #125237;
  --ui-control-success-border: #176344;
  --ui-control-radius: 8px;
  --ui-control-transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease;
}

html[data-theme="dark"] {
  --ui-control-primary-border: #6685a9;
  --ui-control-success-border: #579879;
}

.btn,
.app-feedback-dialog .app-feedback-button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--border, #dce6ed);
  background: var(--surface-alt, #f6f9fb);
  color: var(--text, #34465a);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  box-shadow: none;
  cursor: pointer;
  transition: var(--ui-control-transition);
}

.btn:where(:not(.date-nav-btn, .pn-action, .pl-mode-btn)),
.app-feedback-dialog .app-feedback-button {
  border-radius: var(--ui-control-radius);
}

.btn:hover,
.app-feedback-dialog .app-feedback-button:hover {
  background: var(--surface-hover, #eaf1f6);
  border-color: var(--input-border, #c9d8e2);
  text-decoration: none;
}

.btn:active,
.app-feedback-dialog .app-feedback-button:active {
  background: var(--surface-hover, #eaf1f6);
  border-color: var(--muted, #5b6c80);
  box-shadow: inset 0 1px 2px #10253c14;
}

.btn-sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12.5px;
  line-height: 20px;
  gap: 6px;
}

.btn-primary,
.app-feedback-dialog .app-feedback-button.app-feedback-submit {
  background: var(--ui-control-primary);
  border-color: var(--ui-control-primary-border);
  color: #fff;
  box-shadow: 0 1px 2px #10253c14;
}

.btn-primary:is(:hover, :active),
.app-feedback-dialog .app-feedback-button.app-feedback-submit:is(:hover, :active) {
  background: var(--ui-control-primary-hover);
  border-color: var(--ui-control-primary-border);
  color: #fff;
  box-shadow: 0 1px 3px #10253c24;
}

.btn-secondary,
.btn-ghost {
  background: var(--card, #fff);
  border-color: var(--border, #dce6ed);
  color: var(--text, #34465a);
  box-shadow: none;
}

.btn-ghost { background: transparent; }

.btn-secondary:is(:hover, :active),
.btn-ghost:is(:hover, :active) {
  background: var(--surface-hover, #eaf1f6);
  border-color: var(--input-border, #c9d8e2);
  color: var(--text, #34465a);
}

.btn-danger {
  background: var(--red-bg, #fff0f0);
  border-color: var(--red-border, #f0c5c8);
  color: var(--danger-text, #a83239);
  box-shadow: none;
}

.btn-danger:is(:hover, :active) {
  background: var(--red-bg, #fff0f0);
  background: color-mix(in srgb, var(--red-bg, #fff0f0) 92%, var(--danger-text, #a83239));
  border-color: var(--danger-text, #a83239);
  color: var(--danger-text, #a83239);
}

.btn-success {
  background: var(--ui-control-success);
  border-color: var(--ui-control-success-border);
  color: #fff;
  box-shadow: none;
}

.btn-success:is(:hover, :active) {
  background: var(--ui-control-success-hover);
  border-color: var(--ui-control-success-border);
  color: #fff;
  filter: none;
}

:is(table, [role="grid"], .cons-actions) .btn,
:is(.docs-page, .docs-form) .btn.btn-sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12.5px;
  line-height: 20px;
}

.ui-icon-only { justify-content: center; gap: 0; }

.btn-ico,
.btn.ui-icon-only,
:is(table, [role="grid"], .cons-actions, .docs-page, .docs-form, .toolbar, .page-actions) .btn:is(.btn-ico, .ui-icon-only) {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  gap: 0;
  line-height: 1;
}

span.ui-icon,
.chat-new-btn span.ui-icon,
.pn-action-main > span.ui-icon {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  line-height: 1;
  vertical-align: middle;
  pointer-events: none;
}

/* La spécificité protège les SVG des feuilles de modules chargées ensuite. */
span.ui-icon > svg {
  display: block;
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Le texte source reste copiable, sans subir les styles inline des modules. */
.ui-icon-text {
  position: absolute !important;
  display: block !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.side-link .ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 20px;
}

.side-link .ic.ui-icon,
.side-link .ic .ui-icon,
.side-link .ic svg { width: 20px; height: 20px; }

.nav-grp-title .ui-icon { width: 16px; height: 16px; }
.maintenance-icon .ui-icon { width: 1em; height: 1em; }
a.btn-logout { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; }
a.btn-logout:focus-visible { outline: 2px solid #bcd7f0; outline-offset: 3px; }

.icon-btn,
.nav-ic,
.app-feedback-trigger,
.ui-nav-back,
.navbar .theme-toggle,
.navbar #navToggle {
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  gap: 0;
  border: 1px solid var(--border, #dce6ed);
  border-radius: var(--ui-control-radius);
  background: var(--surface-alt, #f6f9fb);
  color: var(--muted, #5b6c80);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  transition: var(--ui-control-transition);
}

.icon-btn,
.nav-ic,
.app-feedback-trigger,
.ui-nav-back { display: inline-flex; }

.navbar :is(.icon-btn, .nav-ic, .theme-toggle, .app-feedback-trigger, .ui-nav-back) {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
}

.nav-ic.ui-notifications { position: relative; }

:is(.icon-btn, .nav-ic, .app-feedback-trigger, .ui-nav-back):is(:hover, :active),
.navbar .theme-toggle:is(:hover, :active) {
  background: var(--surface-hover, #eaf1f6);
  border-color: var(--input-border, #c9d8e2);
  color: var(--text, #34465a);
  box-shadow: none;
}

.app-feedback-dialog .app-feedback-close,
.app-dlg-close,
.chat-panel :is(.chat-close, .chat-back, .chat-action) {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--border, #dce6ed);
  border-radius: var(--ui-control-radius);
  background: var(--surface-alt, #f6f9fb);
  color: var(--muted, #5b6c80);
  line-height: 1;
  cursor: pointer;
  transition: var(--ui-control-transition);
}

:is(.app-feedback-dialog .app-feedback-close, .app-dlg-close):is(:hover, :active) {
  background: var(--surface-hover, #eaf1f6);
  border-color: var(--input-border, #c9d8e2);
  color: var(--text, #34465a);
}

.chat-panel :is(.chat-close, .chat-back, .chat-action) {
  background: #ffffff0d;
  border-color: #ffffff40;
  color: #fff;
}

.chat-panel :is(.chat-close, .chat-back, .chat-action):is(:hover, :active) {
  background: #ffffff26;
  border-color: #ffffff80;
  color: #fff;
}

body #chat-send {
  box-sizing: border-box;
  flex: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  background: var(--ui-control-primary);
  border: 1px solid var(--ui-control-primary-border);
  color: #fff;
  transition: var(--ui-control-transition);
}

body #chat-send:is(:hover, :active) {
  background: var(--ui-control-primary-hover);
  color: #fff;
}

button.rich-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--card, #fff);
  border-color: var(--border, #dce6ed);
  color: var(--text, #34465a);
  transition: var(--ui-control-transition);
}

button.rich-btn:hover,
button.rich-btn[aria-pressed="true"] {
  background: var(--primary-bg, #edf4fb);
  border-color: var(--focus, #2f6da6);
  color: var(--link, #17588d);
}

.sf-wrap .sf-submit {
  background: var(--navy, var(--brand-navy, #1b2a4a));
  color: #fff;
  transition: var(--ui-control-transition);
}

.sf-wrap .sf-submit:is(:hover, :active) {
  background: var(--blue-dark, var(--brand-deep, #103f66));
}

:is(.btn, .btn-ico, .icon-btn, .nav-ic, .theme-toggle, .ui-nav-back,
    .app-feedback-trigger, .app-feedback-dialog .app-feedback-button, .app-feedback-dialog .app-feedback-close, .app-dlg-close,
    .rich-btn, .pn-action, .sf-submit):is(:disabled, [disabled], .disabled, [aria-disabled="true"]),
.navbar :is(.icon-btn, .nav-ic, .theme-toggle, .app-feedback-trigger, .ui-nav-back):is(:disabled, [disabled], .disabled, [aria-disabled="true"]),
.app-feedback-dialog .app-feedback-button.app-feedback-submit:is(:disabled, [disabled], .disabled, [aria-disabled="true"]),
button.rich-btn:is(:disabled, [disabled], .disabled, [aria-disabled="true"]),
.sf-wrap .sf-submit:is(:disabled, [disabled], .disabled, [aria-disabled="true"]),
body #chat-send:is(:disabled, [disabled], .disabled, [aria-disabled="true"]) {
  background: var(--surface-alt, #f6f9fb);
  border-color: var(--input-border, #c9d8e2);
  border-style: dashed;
  color: var(--muted, #5b6c80);
  opacity: 1;
  filter: none;
  box-shadow: none;
  cursor: not-allowed;
}

.chat-panel :is(.chat-close, .chat-back, .chat-action):is(:disabled, [disabled], .disabled, [aria-disabled="true"]) {
  border-style: dashed;
  border-color: #ffffff59;
  color: #d4e2ef;
  opacity: .8;
  cursor: not-allowed;
}

:is(.btn, .btn-ico, .icon-btn, .nav-ic, .theme-toggle, .ui-nav-back,
    .app-feedback-trigger, .app-feedback-dialog .app-feedback-button, .app-feedback-dialog .app-feedback-close, .app-dlg-close,
    .chat-close, .chat-back, .chat-action, .rich-btn, .pn-action, .sf-submit)[aria-busy="true"],
body #chat-send[aria-busy="true"] {
  border-style: dashed;
  cursor: progress;
}

:is(button, [role="button"], input[type="button"], input[type="submit"], input[type="reset"],
    a.btn, .btn-ico, .icon-btn, .nav-ic, .ui-nav-back, .side-link, .nav-group > summary):focus-visible,
.app-feedback-dialog :is(button, .app-feedback-button, .app-feedback-close):focus-visible,
body #chat-send:focus-visible,
body #chat-fab:focus-visible {
  outline: 2px solid var(--focus, #2f6da6);
  outline-offset: 3px;
}

.chat-panel .chat-header button:focus-visible,
.sidebar :is(.side-link, summary):focus-visible {
  outline-color: #bcd7f0;
}

.btn:is(:hover, :active),
.pn-action:is(:hover, :active),
.pwa-install-btn:is(:hover, :active),
.sf-wrap .sf-submit:is(:hover, :active),
.chat-panel :is(.chat-new-btn, .chat-emoji-item, .chat-reaction, .chat-react-btn):is(:hover, :active),
.chat-panel .chat-react-picker button:is(:hover, :active),
body #chat-fab:is(:hover, :active),
body #popupSensibClose:is(:hover, :active),
body:is(.ambiance-hiver, :not(.ambiance-hiver)) .login-screen .login-box .btn-primary:is(:hover, :active),
body:is(.ambiance-hiver, :not(.ambiance-hiver)) .login-screen .login-box .btn-primary:is(:hover, :active) .btn-arrow {
  transform: none;
}

@media (max-width: 560px) {
  .navbar .breadcrumb { display: none; }

  .navbar .ui-nav-logout {
    flex: none;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    gap: 0;
  }

  .ui-nav-logout > .ui-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

@media (max-width: 359px) {
  .navbar { padding-inline: 6px; gap: 4px; }
  .navbar-right { gap: 3px; }
}

/* La barre de navigation reste compacte sur les téléphones étroits. */
@media (any-pointer: coarse) {
  :is(.page-actions, .app-dlg-body, .cons-dialog-foot) .btn:where(:not(.btn-sm, .btn-ico, .ui-icon-only, table *, [role="grid"] *)),
  .app-feedback-dialog .app-feedback-button {
    min-height: 44px;
  }

  :is(.app-feedback-dialog .app-feedback-close, .app-dlg-close),
  .chat-panel :is(.chat-close, .chat-back, .chat-action),
  body #chat-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
}

@media (any-pointer: coarse) and (min-width: 480px) {
  .navbar :is(.icon-btn, .nav-ic, .theme-toggle, .app-feedback-trigger, .ui-nav-back),
  .navbar #navToggle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Important ciblé pour couvrir les transitions inline historiques du chat. */
  :is(.btn, .btn-ico, .icon-btn, .nav-ic, .theme-toggle, .ui-nav-back,
      .app-feedback-trigger, .app-feedback-dialog .app-feedback-button, .app-feedback-dialog .app-feedback-close, .app-dlg-close,
      .chat-close, .chat-back, .chat-action, .chat-emoji-item, .chat-react-btn, .chat-reaction,
      .rich-btn, .pn-action, .sf-submit, .pwa-install-btn),
  .chat-react-picker button,
  #chat-send,
  #chat-fab,
  #popupSensibClose {
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  :is(.btn, .icon-btn, .nav-ic, .theme-toggle, .app-feedback-trigger,
      .app-feedback-dialog .app-feedback-button, .app-feedback-dialog .app-feedback-close, .app-dlg-close, .ui-nav-back, .rich-btn),
  body #chat-send { border-color: ButtonText; }

  :is(button, [role="button"], a.btn, .nav-ic, .side-link):focus-visible {
    outline-color: Highlight;
  }
}

:is(.btn, .btn-ico, .icon-btn, .nav-ic, .theme-toggle, .app-feedback-trigger,
    .app-feedback-dialog .app-feedback-button, .app-feedback-dialog .app-feedback-close, .app-dlg-close, .ui-nav-back, .rich-btn)[hidden] {
  display: none !important;
}

@media print {
  .app-feedback-trigger { display: none; }
}
