/* Alignement liste + éditeur règles (maquettes tags 02–03). */

.compta-rules-page .compta-rules-card {
  background: #fff;
  border: 1px solid #dfe2eb;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(37, 42, 67, 0.04);
}

.compta-rules-page .compta-rules-card + .compta-rules-card,
.compta-rules-page .compta-rules-layout > .compta-rules-card + .compta-rules-card {
  margin-top: 1rem;
}

.compta-rules-page .compta-rules-fill {
  flex: 1;
}

.compta-rules-page .compta-rules-muted {
  color: #82899d;
}

.compta-rules-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #eceef4;
}

.compta-rules-row:last-child {
  border-bottom: 0;
}

.compta-rules-row--draft {
  background: #f8f9ff;
}

.compta-rules-row__title {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 650;
}

.compta-rules-row__meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.compta-rules-meta {
  color: #82899d;
  font-size: 0.74rem;
}

.compta-rules-row__stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.22rem;
  color: #697084;
  font-size: 0.68rem;
  text-align: right;
}

.compta-rules-row__stats strong {
  color: #353a4a;
  font-size: 0.78rem;
}

.compta-rules-row__actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.15rem;
}

.compta-rules-btn-trash {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #858b9b;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.compta-rules-btn-trash:hover {
  color: #b43845;
  border-color: #df9ca4;
  background: #fff4f5;
}

.compta-rules-ast {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: 0.35rem;
}

.compta-rules-ast__node {
  display: inline-flex;
  padding: 0.28rem 0.48rem;
  border: 1px solid #d8dce8;
  border-radius: 6px;
  background: #f8f9fc;
  color: #555c70;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.compta-rules-ast__op {
  color: #5e6bd0;
  font-weight: 800;
  font-size: 0.68rem;
}

.compta-rules-page .compta-chip--rule-auto {
  border-width: 2px;
}

.compta-rules-page .compta-chip--rule-auto::before {
  content: "⚙";
  font-size: 0.57rem;
  opacity: 0.7;
}

.compta-rules-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0.16rem 0.46rem;
  border-radius: 999px;
  color: #5e6475;
  background: #eff1f6;
  font-size: 0.68rem;
  font-weight: 650;
  white-space: nowrap;
}

.compta-rules-badge--active {
  color: #19704e;
  background: #e5f6ee;
}

.compta-rules-badge--draft {
  color: #8a6416;
  background: #fff5d8;
}

.compta-rules-badge--danger {
  color: #aa3742;
  background: #ffeaec;
}

.compta-rules-layout {
  display: block;
}

.compta-rules-field {
  margin-bottom: 0.9rem;
}

.compta-rules-field > label {
  display: block;
  margin-bottom: 0.32rem;
  color: #697084;
  font-size: 0.7rem;
  font-weight: 700;
}

.compta-rules-then {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid #eceef4;
}

.compta-rules-then > strong {
  font-size: 0.76rem;
}

.compta-rules-then .compta-chips {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  position: relative;
  z-index: 2;
}

.compta-rules-then .compta-tag-add {
  position: relative;
  display: inline-block;
  width: auto;
  height: auto;
}

.compta-rules-then .compta-tag-picker {
  left: 0;
  right: auto;
  z-index: 50;
}

.compta-rules-page .compta-search__ast {
  margin-top: 0.65rem;
}

.compta-rules-modal__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #e8eaf1;
}

.compta-rules-modal__head h3 {
  margin: 0;
  font-size: 0.92rem;
}

.compta-rules-modal__body {
  padding: 1rem;
}

.compta-rules-modal__lead {
  margin: 0 0 1rem;
  color: #6f7689;
  font-size: 0.8rem;
}

.compta-rules-modal__table-wrap {
  overflow-x: auto;
}

.compta-rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.77rem;
}

.compta-rules-table th {
  padding: 0.62rem 0.7rem;
  color: #7b8295;
  border-bottom: 1px solid #e4e6ee;
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.compta-rules-table td {
  padding: 0.68rem 0.7rem;
  border-bottom: 1px solid #eceef4;
  vertical-align: middle;
}

.compta-rules-table tbody tr:last-child td {
  border-bottom: 0;
}

.compta-rules-table tbody tr:hover {
  background: #fafaff;
}

.compta-rules-negative {
  color: #b54752;
}

.compta-rules-tabs {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  min-height: 42px;
  padding: 0 1rem;
  overflow-x: auto;
  border-bottom: 1px solid #e8eaf1;
}

.compta-rules-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.55rem 0.1rem;
  color: #737a8e;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}

.compta-rules-tab.is-active {
  color: #4e5fc3;
  border-bottom-color: #6575de;
}

.compta-rules-delta {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0.2rem 0.48rem;
  border: 1px solid;
  border-radius: 7px;
  font-size: 0.68rem;
  font-weight: 700;
}

.compta-rules-delta--add {
  color: #176b49;
  border-color: #9acdb7;
  background: #edf9f3;
}

.compta-rules-delta--remove {
  color: #a23643;
  border-color: #e0a8ae;
  background: #fff0f1;
}

.compta-rules-delta--keep {
  color: #646b7e;
  border-color: #d4d8e3;
  background: #f7f8fb;
}

.compta-rules-modal-backdrop {
  position: fixed;
  z-index: 120;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(20, 23, 34, 0.52);
  backdrop-filter: blur(2px);
}

.compta-rules-modal {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 2rem));
  overflow: auto;
  background: #fff;
  border: 1px solid #d8dbe5;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(20, 23, 34, 0.3);
}

.compta-rules-modal--wide {
  width: min(920px, 100%);
}

.compta-rules-modal__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid #e6e8ef;
  background: #fafbfc;
}

.compta-rules-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.compta-rules-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid #d9dce6;
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.compta-rules-choice.is-selected {
  border-color: #6575de;
  background: #f5f6ff;
  box-shadow: 0 0 0 2px rgba(101, 117, 222, 0.1);
}

.compta-rules-choice input {
  margin-top: 0.15rem;
  accent-color: #6575de;
}

.compta-rules-choice strong {
  display: block;
  font-size: 0.8rem;
}

.compta-rules-choice small {
  display: block;
  margin-top: 0.3rem;
  color: #747b8e;
  font-size: 0.7rem;
  line-height: 1.45;
}

.compta-rules-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.compta-rules-stat {
  padding: 0.85rem;
  border: 1px solid #e0e3ec;
  border-radius: 9px;
  background: #fbfbfd;
}

.compta-rules-stat span {
  display: block;
  color: #83899a;
  font-size: 0.68rem;
}

.compta-rules-stat strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.05rem;
}

.compta-rules-stat--remove strong {
  color: #ad414c;
}

.compta-rules-callout {
  padding: 0.7rem 0.8rem;
  border: 1px solid #d8ddef;
  border-radius: 8px;
  color: #596076;
  background: #f6f7ff;
  font-size: 0.74rem;
  line-height: 1.45;
}

.compta-rules-stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 0.8rem;
}

.compta-rules-step {
  position: relative;
  color: #959bad;
  font-size: 0.68rem;
  text-align: center;
}

.compta-rules-step::before {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: 0 auto 0.32rem;
  border: 2px solid #cbd0de;
  border-radius: 50%;
  background: #fff;
}

.compta-rules-step::after {
  content: "";
  position: absolute;
  top: 5px;
  left: calc(50% + 7px);
  right: calc(-50% + 7px);
  height: 2px;
  background: #dfe2eb;
}

.compta-rules-step:last-child::after {
  display: none;
}

.compta-rules-step.is-done::before,
.compta-rules-step.is-current::before {
  border-color: #6575de;
  background: #6575de;
}

.compta-rules-step.is-done::after {
  background: #6575de;
}

.compta-rules-step.is-current {
  color: #4e5fc3;
  font-weight: 700;
}

.compta-rules-progress {
  height: 8px;
  overflow: hidden;
  background: #e9ebf2;
  border-radius: 999px;
}

.compta-rules-progress > span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, #6575de, #8b68d9);
  border-radius: inherit;
}

.compta-rules-progress-meta {
  display: flex;
  justify-content: space-between;
  margin: 0.45rem 0 0.75rem;
  color: #777e91;
  font-size: 0.68rem;
}

@media (max-width: 900px) {
  .compta-rules-row {
    grid-template-columns: 1fr;
  }

  .compta-rules-row__stats {
    align-items: flex-start;
    text-align: left;
  }

  .compta-rules-choice-grid,
  .compta-rules-stat-grid {
    grid-template-columns: 1fr;
  }
}
