* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  margin: 0;
  background: #f6f7fb;
  color: #1f2937;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
}

/* En-tete */
.topbar {
  background: #1f2937;
  color: #fff;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  flex-wrap: wrap;
  gap: 8px;
}

.brand {
  font-size: 18px;
  font-weight: 600;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.nav a,
.link-button {
  color: #fff;
  text-decoration: none;
  margin-left: 16px;
  font-size: 14px;
}

.nav a:hover,
.link-button:hover {
  text-decoration: underline;
}

.link-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

main.container {
  flex: 1;
}

/* Pied de page */
.footer {
  background: #e5e7eb;
  font-size: 13px;
  color: #4b5563;
}

.footer .container {
  display: flex;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.footer a {
  color: #1f2937;
}

/* Cartes */
.card {
  background: #fff;
  padding: 24px;
  border-radius: 10px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
  margin-bottom: 24px;
}

.card-narrow {
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1 {
  margin-top: 0;
  font-size: 22px;
}

h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 8px;
}

hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 24px 0;
}

.muted {
  color: #6b7280;
}

.small {
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

.right {
  text-align: right;
}

code {
  font-size: 12px;
  word-break: break-all;
}

/* Indicateurs */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
  font-size: 13px;
  color: #6b7280;
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #1f2937;
}

.stat-value.ok {
  color: #16a34a;
}

.stat-value.warn {
  color: #d97706;
}

.stat-value.danger {
  color: #dc2626;
}

/* Grilles et formulaires */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.field {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

label.checkbox input {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

input:focus,
select:focus {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.filtres {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.filtres-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Boutons */
button.primary,
.primary-link {
  background: #22c55e;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

button.danger {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

a.secondary {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid #1f2937;
  border-radius: 6px;
  color: #1f2937;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.small-btn {
  padding: 4px 10px;
  font-size: 12px;
}

/* Tableaux */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

tbody tr:hover {
  background: #f9fafb;
}

/* Badges de statut */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-payee {
  background: #dcfce7;
  color: #166534;
}

.badge-impayee {
  background: #fef3c7;
  color: #92400e;
}

.badge-en_retard {
  background: #fee2e2;
  color: #991b1b;
}

.badge-annulee {
  background: #e5e7eb;
  color: #4b5563;
}

/* Messages */
.flash-list {
  margin-bottom: 16px;
}

.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 14px;
}

.flash.success {
  background: #dcfce7;
  color: #166534;
}

.flash.error {
  background: #fee2e2;
  color: #991b1b;
}
