* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, Arial, sans-serif; background: #f3f4f6; color: #1f2937; }
a { color: #1d4ed8; }
h1 { margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }

/* En-tête */
.top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; background: #1e3a5f; color: #fff; padding: 10px 24px; }
.top a { color: #fff; text-decoration: none; }
.top nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.top .btn { background: #2563eb; padding: 6px 12px; border-radius: 6px; }
.top .userbox { display: flex; gap: 14px; align-items: center; font-size: .9rem; }
.top .userbox small { opacity: .8; }
.brand { font-weight: 700; font-size: 1.2rem; }

.btn, button { background: #2563eb; color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; cursor: pointer; font-size: .95rem; text-decoration: none; display: inline-block; }
.top nav .btn { color: #fff; }
button.secondary { background: #6b7280; margin-top: 8px; }
button.link { background: none; color: #2563eb; padding: 0; }
button.danger, .danger { color: #dc2626; }
main { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.flash { background: #d1fae5; border: 1px solid #10b981; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash.err { background: #fee2e2; border-color: #ef4444; }
.hint { color: #6b7280; font-size: .85rem; margin: 6px 0; }
small { color: #6b7280; }

/* Formulaires */
input, select { padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .95rem; width: 100%; background: #fff; }
textarea { padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; width: 100%; resize: vertical; }
label { display: flex; flex-direction: column; font-size: .85rem; gap: 4px; color: #4b5563; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: .95rem; color: #1f2937; }
label.check input { width: auto; }
label.check[hidden], option[hidden] { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.span-all { grid-column: 1 / -1; }
.buttons { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
.inline-form { background: #fff; border: 1px solid #d1d5db; border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
.inline-form h2 { margin-top: 0; }
.fiche fieldset { background: #fff; border: 1px solid #d1d5db; border-radius: 8px; margin-bottom: 16px; padding: 14px 16px; }
legend { font-weight: 600; padding: 0 8px; }
.agents-box { margin-top: 14px; }
#agents-list { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 6px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input, .filters select { width: auto; }
.filters input[type=text] { flex: 1; min-width: 240px; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; background: #fff; }
.list th, .list td { padding: 10px; border-bottom: 1px solid #e5e7eb; text-align: left; }
.list th { background: #e5e7eb; }
.list.compact th, .list.compact td { font-size: .82rem; padding: 6px 8px; vertical-align: top; }
.list tfoot td { font-weight: 700; background: #f3f4f6; }
.num-r { text-align: right; white-space: nowrap; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; }
.empty { text-align: center; color: #6b7280; padding: 24px !important; }
.badge { display: inline-block; background: #dbeafe; color: #1e40af; border-radius: 10px; padding: 1px 8px; font-size: .75rem; }
.badge.warn { background: #fef3c7; color: #92400e; }
.lines th, .lines td { padding: 4px; border: 1px solid #e5e7eb; font-size: .85rem; }
.lines .num { width: 32px; text-align: center; }
.diff { text-align: center; font-weight: 700; width: 90px; }
.ok { color: #059669; }
.ko { color: #dc2626; font-weight: 700; }

/* Tableau de bord */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 14px 0; }
.card { background: #fff; border: 1px solid #d1d5db; border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.card .n { font-size: 1.6rem; font-weight: 700; color: #1e3a5f; }
.card.wide { grid-column: span 2; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; }
.actions-bar { display: flex; gap: 12px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.linked { background: #fff; border: 1px solid #d1d5db; border-radius: 8px; padding: 12px 16px; margin-top: 16px; }

/* Fiche imprimable */
.paper { background: #fff; padding: 32px 40px; border: 1px solid #d1d5db; }
.center { text-align: center; }
.underline { text-decoration: underline; }
.info { display: grid; grid-template-columns: 220px 1fr; row-gap: 6px; margin: 20px 0; }
.info dt { font-weight: 600; text-transform: uppercase; font-size: .85rem; }
.info dt.sub { padding-left: 24px; font-weight: 400; text-transform: none; }
.info dd { margin: 0; border-bottom: 1px dotted #6b7280; min-height: 1.2em; }
.info.profil { max-width: 560px; background: #fff; padding: 16px; border: 1px solid #d1d5db; border-radius: 8px; }
.grid-table th, .grid-table td { border: 1px solid #111; padding: 8px; text-align: left; font-size: .9rem; }
.grid-table th { background: #f3f4f6; }

/* Connexion */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1e3a5f; }
.login-card { background: #fff; border-radius: 10px; padding: 28px 32px; width: 100%; max-width: 380px; margin: 16px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { text-align: center; color: #1e3a5f; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    main { margin: 0; max-width: none; }
    .paper { border: 0; padding: 0; }
}
