/* AgentTickets — feuille de style unique (SPEC §14.1).
 * La CSP interdit tout style inline (`style-src 'self'`) : tout le style est
 * ici, piloté par des classes. Thème : variables CSS ; `data-theme` sur
 * <html> force clair ou sombre, sinon `prefers-color-scheme` décide. */

/* ---- Thèmes ------------------------------------------------------------ */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #d6dae1;
  --text: #1c2130;
  --text-muted: #5b6477;
  --accent: #3957d6;
  --accent-hover: #2d47b8;
  --accent-text: #ffffff;
  --danger: #c62f3b;
  --danger-hover: #a8242f;
  --success: #1f8a4c;
  --warning: #a86500;
  --info: #2e6fb5;
  --focus: #6f8cff;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 12px rgb(16 24 40 / 8%);
  --backdrop: rgb(15 18 28 / 45%);
  --radius: 8px;
  --radius-small: 5px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #12151c;
    --surface: #1a1f29;
    --surface-2: #232a36;
    --border: #333c4b;
    --text: #e4e8f0;
    --text-muted: #9aa4b6;
    --accent: #7b93ff;
    --accent-hover: #93a7ff;
    --accent-text: #0f1320;
    --danger: #f06a73;
    --danger-hover: #ff858d;
    --success: #4cc27f;
    --warning: #e0a13a;
    --info: #6aa6ea;
    --focus: #93a7ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 16px rgb(0 0 0 / 35%);
    --backdrop: rgb(0 0 0 / 60%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12151c;
  --surface: #1a1f29;
  --surface-2: #232a36;
  --border: #333c4b;
  --text: #e4e8f0;
  --text-muted: #9aa4b6;
  --accent: #7b93ff;
  --accent-hover: #93a7ff;
  --accent-text: #0f1320;
  --danger: #f06a73;
  --danger-hover: #ff858d;
  --success: #4cc27f;
  --warning: #e0a13a;
  --info: #6aa6ea;
  --focus: #93a7ff;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 16px rgb(0 0 0 / 35%);
  --backdrop: rgb(0 0 0 / 60%);
}

/* ---- Base -------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.2rem;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.9em;
}

.muted {
  color: var(--text-muted);
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.skip-link:focus {
  top: 0.5rem;
}

/* ---- Layout ------------------------------------------------------------ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.main-nav {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-small);
  color: var(--text-muted);
  text-decoration: none;
}

.main-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.main-nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.nav-group {
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-end {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.username {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.counter {
  min-width: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.35rem;
}

.menu-toggle {
  display: none;
}

.app-main {
  padding: 1.25rem;
}

.app-main:focus {
  outline: none;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
}

.centered-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.loading {
  display: grid;
  place-items: center;
  min-height: 50vh;
}

@media (max-width: 860px) {
  .app-header {
    flex-wrap: wrap;
  }

  .menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .main-nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .main-nav.open {
    display: flex;
  }

  .nav-group {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.6rem 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .nav-end {
    flex-direction: column;
    align-items: flex-start;
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.6rem 0;
    border-top: 1px solid var(--border);
  }

  .app-main {
    padding: 0.75rem;
  }
}

/* ---- Boutons ----------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-2);
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.button-ghost {
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.35rem 0.6rem;
}

.button-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent-hover);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  overflow: hidden;
}

.segmented button {
  padding: 0.25rem 0.6rem;
  border: 0;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented button.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

/* ---- Formulaires ------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.field [aria-invalid="true"] {
  border-color: var(--danger);
}

.field-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.form-alert {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius-small);
  color: var(--danger);
  background: var(--surface);
}

.form-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.9rem;
}

/* ---- Connexion --------------------------------------------------------- */

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card .brand {
  margin: 0 0 1rem;
  color: var(--accent);
}

.login-card .button {
  width: 100%;
}

/* ---- Badges, spinner, état vide ---------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.badge-info {
  border-color: var(--info);
  color: var(--info);
}

.badge-success {
  border-color: var(--success);
  color: var(--success);
}

.badge-warning {
  border-color: var(--warning);
  color: var(--warning);
}

.badge-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.spinner {
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

.empty-state {
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

.empty-state-title {
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: var(--text);
}

/* ---- Toasts ------------------------------------------------------------ */

.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-small);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.toast-info {
  border-left-color: var(--info);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-text {
  flex: 1;
}

.toast-close {
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

/* ---- Modales ----------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--backdrop);
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal:focus {
  outline: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 0.5rem;
}

.modal-header h2 {
  margin: 0;
}

.modal-body {
  padding: 0.5rem 1.25rem 1.25rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ---- Éditeur et rendu markdown ----------------------------------------- */

.markdown-editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tabs {
  display: inline-flex;
  gap: 0.25rem;
}

.tabs button {
  padding: 0.2rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.tabs button.active {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.markdown-preview {
  min-height: 8rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.markdown {
  overflow-wrap: anywhere;
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown pre {
  padding: 0.75rem;
  overflow-x: auto;
  border-radius: var(--radius-small);
  background: var(--surface-2);
}

.markdown code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--surface-2);
}

.markdown pre code {
  padding: 0;
  background: none;
}

.markdown blockquote {
  margin: 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
}

.markdown table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.markdown th,
.markdown td {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
}

.markdown th {
  background: var(--surface-2);
}

.markdown img {
  max-width: 100%;
}

.markdown li:has(> input[type="checkbox"]) {
  list-style: none;
}

.markdown input[type="checkbox"] {
  margin: 0 0.4rem 0 -1.2rem;
}

/* ---- Tableau (SPEC §14.2, écran 2) ------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.board-page {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: calc(100vh - 8rem);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.filter select,
.filter input[type="search"] {
  padding: 0.35rem 0.5rem;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.filter-search input {
  min-width: 14rem;
}

.filter-toggle {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  padding-bottom: 0.35rem;
}

.connection {
  margin-left: auto;
  padding-bottom: 0.35rem;
}

.connection .dot {
  background: var(--text-muted);
}

.connection-live .dot {
  background: var(--success);
}

.connection-retry .dot {
  background: var(--warning);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .connection-retry .dot {
    animation: none;
  }
}

.board {
  display: flex;
  flex: 1;
  gap: 0.75rem;
  min-height: 0;
  padding-bottom: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.column {
  display: flex;
  flex-direction: column;
  flex: 0 0 19rem;
  min-height: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.column-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.column-header h2 {
  margin: 0;
  font-size: 0.95rem;
}

.column-color {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
}

.column-count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.column-header .icon-button {
  margin-left: auto;
}

.column-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 3rem;
  padding: 0.5rem;
  overflow-y: auto;
  /* Le défilement natif reste possible dans les deux axes (colonne et
   * board) : le glissement tactile ne démarre qu'après un appui long de
   * 250 ms, après quoi le module dnd empêche le panoramique (§14.3). */
  touch-action: pan-x pan-y;
}

.column-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow);
  cursor: grab;
  touch-action: pan-x pan-y;
}

.card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.card-question {
  border-color: var(--warning);
  box-shadow: 0 0 0 1px var(--warning);
}

.card-archived {
  opacity: 0.6;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.card-key {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-title {
  margin: 0;
  font-weight: 600;
  line-height: 1.3;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.card-claim {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.claim-agent {
  font-weight: 600;
}

.claim-lease {
  font-variant-numeric: tabular-nums;
}

.claim-note {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
}

.dot-fresh {
  background: var(--success);
}

.dot-late {
  background: var(--warning);
}

.dot-stale {
  background: var(--danger);
}

/* ---- Glisser-déposer (SPEC §14.3) -------------------------------------- */

.dnd-source {
  display: none;
}

.dnd-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
  opacity: 0.9;
  transform: translate(0, 0);
  rotate: 1.5deg;
}

body.dnd-dragging {
  cursor: grabbing;
  user-select: none;
  touch-action: none;
}

body.dnd-dragging .card {
  cursor: grabbing;
}

.card-placeholder {
  min-height: 3.5rem;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.move-menu {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dialog-target {
  font-weight: 600;
}

@media (max-width: 720px) {
  .board-page {
    height: calc(100vh - 10rem);
  }

  .column {
    flex-basis: 85vw;
  }
}

/* ---- Détail du ticket (§14.2, écran 3) --------------------------------- */

/* Panneau latéral par-dessus le board sur desktop ; page pleine sur mobile
 * (le board reste monté : la règle < 1024 px le masque pour éviter un ordre
 * de tabulation derrière la page). */
.ticket-panel {
  position: fixed;
  inset: 4rem 0 0 auto;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(40rem, 50vw);
  padding: 0.75rem 1rem 1rem;
  overflow-y: auto;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.25rem;
  background: var(--surface);
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-title {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.panel-title .field {
  flex: 1;
}

.panel-meta,
.panel-claim,
.panel-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.panel-claim {
  padding: 0.4rem 0.6rem;
  background: var(--surface-2);
  border-radius: var(--radius-small);
}

.panel-dates,
.panel-attempts {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.panel-tabs {
  flex-wrap: wrap;
}

/* Never shrinks below its content: the panel itself scrolls, and the
 * actions stay under the tab panel instead of overlapping it. */
.panel-body {
  flex: 1 0 auto;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  border: 1px solid var(--warning);
  border-radius: var(--radius-small);
}

.field-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tab-description,
.tab-criteria,
.tab-relations,
.tab-git,
.tab-discussion,
.tab-reports,
.tab-history,
.tab-context {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tab-actions,
.criterion-add,
.link-add,
.context-bar,
.inbox-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.criterion-add .field,
.link-add .field {
  flex: 1;
}

/* ---- Critères (§4.4) --------------------------------------------------- */

.criteria-list,
.relation-list,
.link-list,
.comment-list,
.report-list,
.event-list,
.inbox-list,
.search-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.criterion {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.5rem;
  padding: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  cursor: grab;
}

.criterion:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.criterion.checked .criterion-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

.criterion-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.criterion-check .field {
  flex: 1;
  margin: 0;
}

.criterion-meta,
.criterion-actions,
.comment-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.criterion-note {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.criterion-note .field {
  flex: 1;
}

/* ---- Relations (§4.5, §4.6) -------------------------------------------- */

.relation,
.git-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.35rem 0.5rem;
  background: var(--surface-2);
  border-radius: var(--radius-small);
}

.relation a,
.git-link a {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
}

.dependency-unmet {
  color: var(--warning);
}

.ticket-search {
  position: relative;
}

.search-results:empty {
  display: none;
}

.search-results button {
  width: 100%;
  justify-content: flex-start;
  gap: 0.5rem;
}

/* ---- Discussion (§4.7, §4.10) ------------------------------------------ */

.pinned-question {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  border: 1px solid var(--warning);
  border-radius: var(--radius);
}

.pinned-question h3 {
  margin: 0;
}

.comment {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.comment-question {
  border-color: var(--warning);
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.comment-author,
.report-agent {
  font-weight: 600;
}

.comment-new {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

/* ---- Rapports (§4.8) --------------------------------------------------- */

.report {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.65rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.report-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.report h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.report ul {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}

.report-warnings {
  padding: 0.4rem 0.6rem;
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-small);
}

.report-follow-ups li,
.report-criteria li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Historique et contexte agent -------------------------------------- */

.event {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: var(--surface-2);
  border-radius: var(--radius-small);
  font-size: 0.9rem;
}

.event-type {
  font-weight: 600;
}

.event-actor {
  color: var(--text-muted);
}

.context-bar {
  justify-content: space-between;
}

.context-stage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.context-json {
  max-height: 32rem;
  overflow: auto;
}

/* ---- Inbox (§14.2, écran 5) -------------------------------------------- */

.inbox-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.inbox-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.inbox-head,
.inbox-pr,
.inbox-report {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.inbox-question {
  margin: 0;
  padding: 0.5rem 0.65rem;
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-small);
  white-space: pre-wrap;
}

/* ---- Création et aide clavier ------------------------------------------ */

.create-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.create-parent,
.create-dependencies {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
}

.shortcut {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.shortcut dt {
  flex: 0 0 5rem;
}

.shortcut dd {
  margin: 0;
}

kbd {
  padding: 0.1rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-small);
}

/* Mobile (AC10) : le détail occupe toute la page et le board disparaît. */
@media (max-width: 1023px) {
  .ticket-panel {
    inset: 3.5rem 0 0 0;
    width: 100%;
    border-left: none;
  }

  .board-page.panel-open .board,
  .board-page.panel-open .filter-bar {
    display: none;
  }

  .criterion {
    grid-template-columns: 1fr;
  }
}

/* ---- Paramètres : contrôles partagés (§14.2, écrans 6 à 9) ------------- */

.field-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

.field-check input {
  width: 1rem;
  height: 1rem;
}

.field-check label {
  font-weight: 500;
}

.field-check .field-hint {
  grid-column: 2;
}

.field-color .color-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.field-color .color-row input[type="color"] {
  width: 3rem;
  height: 2.4rem;
  padding: 0.15rem;
}

.field-color .color-row .field {
  flex: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.2rem 0.1rem 0.5rem;
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.tag-remove {
  padding: 0 0.3rem;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.tag-remove:hover {
  color: var(--danger);
}

.tags-add {
  display: flex;
  gap: 0.5rem;
}

.tags-add input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.copy {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-feedback {
  color: var(--success);
  font-size: 0.85rem;
}

.warning {
  margin: 0;
  padding: 0.5rem 0.7rem;
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border: 1px solid var(--warning);
  border-radius: var(--radius-small);
  font-size: 0.9rem;
}

.violations {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.4rem 0 0;
  padding: 0.4rem 0.7rem;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid var(--danger);
  border-radius: var(--radius-small);
  list-style: none;
  font-size: 0.88rem;
}

.settings-block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 44rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.settings-block h2,
.settings-block h3 {
  margin: 0;
}

fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

legend {
  padding: 0 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ---- Paramètres → Colonnes (§14.2, écran 6) ---------------------------- */

.columns-settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 60rem;
}

.column-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.column-row {
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  cursor: grab;
}

.column-row:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.column-row.invalid {
  border-color: var(--danger);
}

.column-row.dragging {
  opacity: 0.5;
}

.column-row-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.column-swatch {
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
}

.column-row-name {
  flex: 1;
  font-weight: 600;
}

.column-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  cursor: auto;
}

.column-limits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}

.column-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Schéma du pipeline : SVG calculé en direct, sans bibliothèque JS. */
.pipeline {
  margin: 0;
  padding: 0.75rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pipeline figcaption {
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.pipeline-graph {
  display: block;
  width: 100%;
  min-width: 40rem;
  height: 11rem;
}

.pipeline-legend {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.graph-edge {
  stroke: var(--text-muted);
  stroke-width: 2;
}

.graph-reject {
  stroke-dasharray: 5 4;
}

.graph-edge.graph-invalid {
  stroke: var(--danger);
  stroke-width: 3;
}

.graph-node-box {
  stroke: var(--border);
  stroke-width: 1;
}

.graph-node.graph-invalid .graph-node-box {
  stroke: var(--danger);
  stroke-width: 3;
}

.graph-node-name {
  fill: #ffffff;
  font-size: 13px;
  font-weight: 600;
  paint-order: stroke;
  stroke: rgb(0 0 0 / 35%);
  stroke-width: 3px;
}

.graph-node-kind {
  fill: #ffffff;
  font-size: 11px;
  paint-order: stroke;
  stroke: rgb(0 0 0 / 35%);
  stroke-width: 3px;
}

/* ---- Paramètres → Dépôts (§14.2, écran 7) ------------------------------ */

.repo-add {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 44rem;
  margin-bottom: 1.5rem;
}

.repo-add .field {
  flex: 1;
}

.repo-list,
.agent-list,
.token-list,
.session-list,
.agent-claims,
.push-test {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.repo-row,
.agent-row {
  max-width: 60rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.repo-row.archived {
  opacity: 0.6;
}

.repo-head,
.agent-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.repo-name,
.agent-name {
  flex: 1;
  font-weight: 600;
}

.repo-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.repo-error {
  color: var(--danger);
}

.repo-description {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
}

.repo-form,
.agent-form,
.agent-create {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ---- Paramètres → Agents (§14.2, écran 8) ------------------------------ */

.agent-claims {
  margin-top: 0.4rem;
  font-size: 0.88rem;
}

.agent-tokens,
.agent-snippets {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.agent-tokens h3,
.agent-snippets h3,
.token-create h4 {
  margin: 0 0 0.5rem;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-size: 0.88rem;
}

.token-row.revoked,
.token-row.expired {
  opacity: 0.6;
}

.token-label {
  font-weight: 600;
}

.token-prefix {
  font-family: var(--mono);
}

.token-create {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.token-secret,
.snippet {
  padding: 0.6rem;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- Paramètres → Compte (§14.2, écran 9) ------------------------------ */

.totp-setup {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.totp-qr {
  width: 12rem;
  height: 12rem;
  padding: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.totp-uri code {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

.recovery-codes {
  padding: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--warning);
  border-radius: var(--radius-small);
}

.recovery-codes ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.3rem;
  margin: 0.6rem 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
}

.session-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-size: 0.88rem;
}

.session-row.current {
  border-color: var(--info);
}

.session-agent {
  flex: 1;
  word-break: break-word;
}

.ntfy-topic {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.ntfy-topic .field {
  flex: 1;
}

.ntfy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ntfy-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-size: 0.88rem;
}

.push-test {
  font-size: 0.9rem;
}

/* Abonnement Web Push de l'appareil courant (PWA, §14.5). */
.push-device {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.push-device h4 {
  margin: 0;
  font-size: 0.95rem;
}

.push-device-state {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.push-device .warning {
  margin: 0;
}

@media (max-width: 720px) {
  .repo-add,
  .ntfy-topic,
  .field-color .color-row {
    flex-direction: column;
    align-items: stretch;
  }

  .pipeline-graph {
    min-width: 32rem;
  }
}
