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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #222;
}

main {
  max-width: 900px;
  margin: 0 auto 2rem auto;
  padding: 1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f5f5f5;
  padding: 0.75rem 1rem 0.75rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.topbar h1 {
  font-size: 1.4rem;
  margin: 0;
}

.subtitle {
  margin: 0.1rem 0 0.4rem 0;
  font-size: 0.9rem;
  color: #555;
}

.status-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}

.status {
  font-weight: 600;
}

.status.ok {
  color: #2e7d32;
}

.status.ko {
  color: #c62828;
}

.top-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

button {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.45rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  background: #0b6efd;
  color: #fff;
}

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

button.ghost {
  background: #eee;
  color: #333;
}

button.small {
  padding: 0.25rem 0.8rem;
  font-size: 0.8rem;
}

button:active {
  transform: translateY(1px);
}

.card {
  background: #ffffff;
  margin-top: 1rem;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.subcard {
  border-top: 1px solid #eee;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.subcard:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.section-letter {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0b6efd;
  color: white;
  font-weight: 700;
}

.section-header h2 {
  margin: 0;
  font-size: 1rem;
}

.items {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.3rem;
}

label {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.9rem;
}

input[type="checkbox"] {
  margin-top: 0.1rem;
  transform: scale(1.2);
}

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

.field-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.field-group {
  flex: 1 1 0;
  min-width: 140px;
}

.field-group label {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.field-group input,
.field-group select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
}

.field-group textarea {
  width: 100%;
  min-height: 60px;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
  resize: vertical;
}

.help-text {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: #666;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-table-wrapper {
  margin-top: 0.5rem;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid #eee;
  padding: 0.35rem 0.4rem;
  text-align: left;
}

.history-table th {
  font-weight: 600;
  background: #fafafa;
}

.history-table td.status-ok {
  color: #2e7d32;
  font-weight: 600;
}

.history-table td.status-ko {
  color: #c62828;
  font-weight: 600;
}

@media (min-width: 900px) {
  main {
    padding-top: 1.25rem;
  }
}

/* Styles d'impression pour le PDF */
@media print {
  body {
    background: #ffffff;
  }
  .topbar,
  .top-buttons,
  .help-text,
  .history-header,
  #btn-clear-history {
    display: none !important;
  }
  main {
    max-width: 100%;
    margin: 0;
    padding: 0.5rem;
  }
  .card {
    box-shadow: none;
    border-radius: 0;
    margin-top: 0.5rem;
  }
}