/* Front table refresh: consistent spacing, stable actions column, accessible focus states, responsive cards */
.utm-wrapper {
  --utm-border-color: #e2e8f0;
  --utm-surface: #ffffff;
  --utm-subtle-surface: #f8fafc;
  --utm-hover: #f1f5f9;
  --utm-accent-bg: #dbeafe;
  --utm-accent-border: #bfdbfe;
  --utm-accent-text: #1d4ed8;
  --utm-ghost-bg: #f8fafc;
  --utm-ghost-border: #e2e8f0;
  --utm-ghost-text: #0f172a;
  --utm-danger-bg: #fee2e2;
  --utm-danger-border: #fecaca;
  --utm-danger-text: #b91c1c;
  --utm-muted-text: #64748b;
  --utm-strong-text: #111827;
  --utm-radius-lg: 14px;
  --utm-radius-sm: 10px;
  --utm-transition: 0.22s ease;
  --utm-table-font-size: 0.95rem;
  --utm-table-line-height: 1.45;
  --utm-table-cell-y: 12px;
  --utm-table-cell-x: 14px;
  --utm-table-min-width: 520px;
  --utm-table-layout: auto;
  margin: 0 0 24px;
}

.utm-wrapper--density-comfortable {
  --utm-table-font-size: 0.95rem;
  --utm-table-line-height: 1.45;
  --utm-table-cell-y: 12px;
  --utm-table-cell-x: 14px;
  --utm-table-min-width: 520px;
  --utm-table-layout: auto;
}

.utm-wrapper--density-compact {
  --utm-table-font-size: 0.9rem;
  --utm-table-line-height: 1.4;
  --utm-table-cell-y: 10px;
  --utm-table-cell-x: 12px;
  --utm-table-min-width: 420px;
  --utm-table-layout: auto;
}

.utm-wrapper--density-condensed {
  --utm-table-font-size: 0.85rem;
  --utm-table-line-height: 1.35;
  --utm-table-cell-y: 8px;
  --utm-table-cell-x: 10px;
  --utm-table-min-width: 360px;
  --utm-table-layout: auto;
}

.utm-wrapper--density-ultra {
  --utm-table-font-size: 0.8rem;
  --utm-table-line-height: 1.3;
  --utm-table-cell-y: 6px;
  --utm-table-cell-x: 8px;
  --utm-table-min-width: 320px;
  --utm-table-layout: auto;
}

.utm-title {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--utm-strong-text);
}

.utm-table-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--utm-surface);
}

.utm-table-scroll::after {
  content: "";
  position: sticky;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 8px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(248, 250, 252, 0),
    rgba(15, 23, 42, 0.05)
  );
}

.utm-table {
  width: 100%;
  border-collapse: collapse;
  min-width: var(--utm-table-min-width);
  table-layout: var(--utm-table-layout);
  background: var(--utm-surface);
  color: var(--utm-strong-text);
}

.utm-table th,
.utm-table td {
  padding: var(--utm-table-cell-y) var(--utm-table-cell-x);
  border-bottom: 1px solid var(--utm-border-color);
  text-align: left;
  font-size: var(--utm-table-font-size);
  line-height: var(--utm-table-line-height);
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition: background-color var(--utm-transition),
    box-shadow var(--utm-transition), color var(--utm-transition);
}

.utm-table th {
  background: var(--utm-subtle-surface);
  font-weight: 600;
  color: var(--utm-strong-text);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  overflow: visible;
}

.utm-table tbody tr {
  transition: background-color var(--utm-transition),
    box-shadow var(--utm-transition);
}

.utm-table tbody tr:nth-child(odd) td {
  background: var(--utm-surface);
}

.utm-table tbody tr:nth-child(even) td {
  background: rgba(59, 130, 246, 0.06);
}

.utm-table tbody tr:hover td {
  box-shadow: none;
}

.utm-table tbody tr:nth-child(odd):hover td {
  background: var(--utm-surface);
}

.utm-table tbody tr:nth-child(even):hover td {
  background: rgba(59, 130, 246, 0.06);
}

.utm-table tbody tr:focus-within td,
.utm-table tbody tr[data-row-state="active"] td {
  background: rgba(59, 130, 246, 0.14);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.utm-table tbody td:first-child,
.utm-table tbody td:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.utm-sort {
  vertical-align: middle;
  white-space: nowrap;
  text-align: left;
}

.utm-sort__inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
  width: auto;
}

.utm-sort__label {
  flex: 0 1 auto;
  min-width: 0;
  display: block;
  padding-right: 6px;
}

.utm-sort__controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}

.utm-sort__btn {
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  padding: 0;
  width: 24px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.utm-sort__btn:hover,
.utm-sort__btn:focus-visible {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #1e293b;
}

.utm-sort__btn.is-active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 6px 16px -12px rgba(37, 99, 235, 0.6);
}

.utm-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.utm-table__actions {
  width: 96px;
  min-width: 96px;
  text-align: center;
  white-space: nowrap;
  padding-left: 12px;
  padding-right: 12px;
}

.utm-table td.utm-table__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.utm-table td.utm-table__actions .utm-row-actions {
  width: auto;
}

.utm-table thead th.utm-table__actions > span[aria-hidden="true"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.utm-table__actions-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.utm-cell-placeholder {
  color: var(--utm-muted-text);
}

.utm-row-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.95rem;
}

.utm-row-actions__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--utm-ghost-text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color var(--utm-transition);
}

.utm-row-actions__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 24px;
  line-height: 1;
}

.utm-row-actions__icon::before {
  width: 24px;
  height: 24px;
  line-height: 1;
}

.utm-row-actions__toggle:hover,
.utm-row-actions__toggle:focus-visible {
  background: transparent;
  color: var(--utm-ghost-text);
}

.utm-row-actions.is-open .utm-row-actions__toggle {
  background: transparent;
  color: var(--utm-ghost-text);
}

.utm-row-actions__toggle:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.utm-row-actions__menu {
  position: absolute;
  top: calc(100% + 3px);
  right: 0;
  min-width: 180px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--utm-border-color);
  background: var(--utm-surface);
  box-shadow: 0 12px 32px -16px rgba(15, 23, 42, 0.16);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1200;
}

.utm-row-actions__menu[hidden] {
  display: none;
}

.utm-row-actions__menu.is-above {
  transform-origin: bottom right;
}

.utm-row-actions__menu.is-below {
  transform-origin: top right;
}

.utm-row-actions__item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--utm-ghost-text);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.utm-row-actions__item:hover,
.utm-row-actions__item:focus-visible {
  outline: none;
}

.utm-row-actions__item.is-danger {
  color: var(--utm-danger-text);
}

.utm-row-actions__item.is-danger:hover,
.utm-row-actions__item.is-danger:focus-visible {
  background: #feecef;
}

.utm-empty {
  margin: 12px 0 20px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed #cbd5f5;
  background: #f8fafc;
  color: #475569;
  font-size: 0.9rem;
}

.utm-form {
  margin-top: 28px;
}

.utm-form h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: #0f172a;
}

.utm-form__intro,
.utm-form__hint {
  margin: 0;
  font-size: 0.9rem;
  color: #475569;
}

.utm-form__hint {
  color: #64748b;
}

.utm-form__body {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.utm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.utm-field__label {
  font-weight: 600;
  color: #0f172a;
}

.utm-required {
  color: #dc2626;
  margin-left: 4px;
}

.utm-input,
.utm-textarea,
.utm-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.utm-textarea {
  min-height: 100px;
  resize: vertical;
}

.utm-input:focus,
.utm-textarea:focus,
.utm-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.utm-input.is-error,
.utm-textarea.is-error,
.utm-select.is-error {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.utm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.utm-btn {
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  border: 1px solid transparent;
  background: var(--utm-ghost-bg);
  color: var(--utm-ghost-text);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease,
    color 0.2s ease, box-shadow 0.2s ease;
}

.utm-btn:focus-visible {
  outline: 2px solid var(--utm-accent-border);
  outline-offset: 2px;
}

.utm-btn--primary {
  background: var(--utm-accent-bg);
  border-color: var(--utm-accent-border);
  color: var(--utm-accent-text);
  box-shadow: none;
}

.utm-btn:hover,
.utm-btn:focus-visible:hover {
  background: var(--utm-ghost-bg);
  border-color: transparent;
  color: var(--utm-ghost-text);
}

.utm-btn--primary:hover {
  background: var(--utm-accent-bg);
  border-color: var(--utm-accent-border);
  color: var(--utm-accent-text);
}

.utm-btn--ghost {
  background: var(--utm-ghost-bg);
  border-color: var(--utm-ghost-border);
  color: var(--utm-ghost-text);
}

.utm-btn--ghost:hover {
  background: var(--utm-ghost-bg);
  border-color: var(--utm-ghost-border);
  color: var(--utm-ghost-text);
}

.utm-btn--danger {
  background: var(--utm-danger-bg);
  border-color: var(--utm-danger-border);
  color: var(--utm-danger-text);
}

.utm-btn--danger:hover {
  background: #fecaca;
  border-color: var(--utm-danger-border);
  color: var(--utm-danger-text);
}

.utm-status {
  min-height: 1.2em;
  font-size: 0.9rem;
  color: #2563eb;
}

.utm-status.is-error {
  color: #dc2626;
}

.utm-status.is-visible {
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
}

.utm-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.utm-header__title {
  flex: 1 1 200px;
  min-width: 0;
}

.utm-actions-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
}

.utm-year-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.utm-year-filter__label {
  font-size: 0.95rem;
  color: var(--utm-muted-text);
}

.utm-year-filter__select {
  min-width: 120px;
}

.utm-export-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.utm-export-controls__label {
  font-size: 0.95rem;
  color: var(--utm-muted-text);
  margin-right: 4px;
}

.utm-export-controls__select {
  min-width: 140px;
}

.utm-export-controls .utm-btn {
  white-space: nowrap;
}

.utm-actions-bar .utm-status {
  margin-left: 0;
}

.utm-pagination {
  margin: 16px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.utm-pagination__summary {
  font-size: 0.9rem;
  color: #475569;
}

.utm-pagination__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.utm-pagination__links .page-numbers {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.utm-pagination__links .page-numbers:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.utm-pagination__links .page-numbers.current {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-color: transparent;
}

.utm-pagination__links .page-numbers.dots {
  background: transparent;
  border-color: transparent;
  color: #94a3b8;
  cursor: default;
}

.utm-btn--ghost {
  background: var(--utm-ghost-bg);
  color: var(--utm-ghost-text);
  border-color: var(--utm-ghost-border);
}

.utm-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.utm-modal[hidden] {
  display: none !important;
}

.utm-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.utm-modal__dialog {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border-radius: 16px;
  padding: 28px;
  width: min(100%, 600px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px -24px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.utm-modal__dialog h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #0f172a;
}

.utm-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #475569;
  cursor: pointer;
}

.utm-modal__close:hover {
  color: #1e293b;
}

@media (max-width: 720px) {
  .utm-table {
    min-width: 0;
  }

  .utm-table thead {
    display: none;
  }

  .utm-table tbody {
    display: block;
  }

  .utm-table tbody tr {
    display: block;
    border: 1px solid var(--utm-border-color);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: var(--utm-surface);
  }

  .utm-table tbody td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 0;
    border-bottom: none;
  }

  .utm-table tbody td + td {
    border-top: 1px solid var(--utm-border-color);
  }

  .utm-table tbody td:first-child {
    border-top: none;
  }

  .utm-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--utm-muted-text);
    margin-right: 0;
  }

  .utm-table__actions {
    width: auto;
    text-align: right;
  }

  .utm-table tbody td.utm-table__actions {
    align-items: flex-end;
    gap: 6px;
  }

  .utm-table tbody td.utm-table__actions .utm-row-actions {
    width: auto;
  }

  .utm-row-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }
}

.utm-modal__intro,
.utm-modal__hint {
  margin: 0;
  font-size: 0.95rem;
  color: #475569;
}

.utm-modal__hint {
  color: #64748b;
}

body.utm-modal-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  .utm-table {
    min-width: 100%;
  }

  .utm-sort__inner {
    align-items: flex-start;
  }

  .utm-pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .utm-pagination__links {
    justify-content: flex-start;
  }

  .utm-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .utm-header__title {
    width: 100%;
  }

  .utm-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .utm-status {
    align-self: flex-start;
  }

  .utm-actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-left: 0;
  }

  .utm-year-filter {
    width: 100%;
    margin-right: 0;
    justify-content: space-between;
  }

  .utm-year-filter__select {
    width: 100%;
  }

  .utm-export-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .utm-export-controls__select {
    width: 100%;
  }

  .utm-export-controls .utm-btn {
    width: 100%;
  }

  .synthese-statistiques__header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .synthese-statistiques__filters {
    width: 100%;
    justify-content: space-between;
  }

  .synthese-statistiques__filters-select {
    width: 100%;
  }

  .utm-actions-bar .utm-status {
    margin-left: 0;
  }

  .utm-modal {
    padding: 16px;
  }

  .utm-modal__dialog {
    width: 100%;
    max-height: 95vh;
    padding: 22px;
    border-radius: 12px;
  }

  .utm-modal__close {
    top: 12px;
    right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .utm-table tbody tr,
  .utm-table tbody td,
  .utm-row-actions__toggle,
  .utm-btn,
  .utm-sort__btn {
    transition: none;
  }
}

.synthese-statistiques {
  margin: 32px 0;
  padding: 24px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  display: block;
  gap: 24px;
}

.synthese-statistiques h2 {
  margin: 0 0 24px;
  text-align: center;
  font-size: 1.6rem;
  line-height: 1.3;
  color: #0f172a;
}

.synthese-statistiques__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.synthese-statistiques__filters {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.synthese-statistiques__filters-label {
  font-size: 0.95rem;
  color: #475569;
}

.synthese-statistiques__filters-select {
  min-width: 140px;
}

.synthese-statistiques__empty {
  margin: 0;
  text-align: center;
  font-size: 1rem;
  color: #475569;
}

.synthese-statistiques .tableau-incidents,
.synthese-statistiques .tableau-actions {
  margin-bottom: 24px;
  overflow-x: auto;
}

.synthese-statistiques > .tableau-incidents:last-child,
.synthese-statistiques > .tableau-actions:last-child {
  margin-bottom: 0;
}

.synthese-statistiques .synthese-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 320px;
  background: #ffffff;
}

.synthese-statistiques .synthese-table th,
.synthese-statistiques .synthese-table td {
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  text-align: center;
  font-size: 0.95rem;
  color: #0f172a;
}

.synthese-statistiques .synthese-table th {
  background: #f8fafc;
  font-weight: 600;
}

.synthese-statistiques .synthese-table th:first-child,
.synthese-statistiques .synthese-table td:first-child {
  text-align: left;
}

.synthese-statistiques .synthese-table tbody tr:nth-child(odd) td {
  background: #ffffff;
}

.synthese-statistiques .synthese-table tbody tr:nth-child(even) td {
  background: #f8fafc;
}

.synthese-statistiques .synthese-table tbody tr:hover td {
  background: #edf2f7;
}

.synthese-statistiques .synthese-table td:last-child {
  font-weight: 600;
}

@media (min-width: 960px) {
  .synthese-statistiques {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }

  .synthese-statistiques h2 {
    margin-bottom: 0;
  }

  .synthese-statistiques__header {
    align-items: center;
  }

  .synthese-statistiques__filters {
    width: auto;
  }

  .synthese-statistiques .tableau-incidents,
  .synthese-statistiques .tableau-actions {
    margin-bottom: 0;
  }
}
