:root {
  --bg: #f5f7f3;
  --panel: #ffffff;
  --text: #1f2a24;
  --muted: #66746c;
  --green: #1f6f52;
  --green-dark: #15513c;
  --green-light: #e8f5ee;
  --orange: #e8873a;
  --border: #dce4dd;
  --warning-bg: #fff6e8;
  --warning-border: #f0b36b;
  --shadow: 0 14px 35px rgba(31, 42, 36, 0.07);
  --radius: 18px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 28px 36px;
  background: linear-gradient(135deg, #153f2e, #1f6f52);
  color: white;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.75;
  margin: 0 0 8px;
}

h1, h2 { margin: 0; }

h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

.subtitle {
  margin: 8px 0 0;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.82);
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6ef0b2;
  flex-shrink: 0;
  animation: pulse-dot 2.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Layout ── */

.layout {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 20px;
  padding: 24px;
  max-width: 1420px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.history-panel {
  grid-column: 1 / -1;
}

/* ── Typographie ── */

.hint, .disclaimer {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 4px;
}

.disclaimer {
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--green-light);
  border-radius: 10px;
  border: 1px solid #c8e8d6;
}

/* ── Formulaire ── */

label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  margin: 18px 0 6px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: #fbfdfb;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2366746c' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

textarea { resize: vertical; line-height: 1.55; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 111, 82, 0.12);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-row > div > label {
  margin-top: 18px;
}

/* ── Draft wrapper & compteur ── */

.draft-wrapper {
  position: relative;
}

.draft-wrapper textarea {
  padding-bottom: 28px;
}

.char-count {
  position: absolute;
  bottom: 9px;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
  background: rgba(251, 253, 251, 0.92);
  padding: 2px 7px;
  border-radius: 6px;
}

/* ── Boutons ── */

.actions {
  display: flex;
  gap: 9px;
  margin-top: 18px;
}

.actions.wrap { flex-wrap: wrap; }

button {
  border: 1px solid var(--border);
  background: white;
  border-radius: 11px;
  padding: 10px 15px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  transition: background 0.14s, border-color 0.14s, transform 0.1s, box-shadow 0.14s;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #c4d4c8;
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

button.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

button.primary:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

/* ── Section header ── */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

/* ── Badge ── */

.badge {
  color: var(--green-dark);
  background: var(--green-light);
  border: 1px solid #c2e2d0;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge--brouillon {
  color: #5a5f5c;
  background: #f0f2f0;
  border-color: #d4d8d5;
}

.badge--validé {
  color: var(--green-dark);
  background: var(--green-light);
  border-color: #c2e2d0;
}

.badge--archivé {
  color: #3a4f6e;
  background: #eaf0f8;
  border-color: #c0d0e4;
}

.hidden { display: none; }

/* ── Alertes de prudence ── */

.warnings {
  margin: 14px 0;
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  font-size: 14px;
}

.warnings strong {
  display: block;
  margin-bottom: 6px;
  color: #a05a10;
}

.warnings ul {
  margin: 0;
  padding-left: 18px;
  color: #7a4408;
  line-height: 1.6;
}

/* ── Historique ── */

.history-item {
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 13px 16px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.history-item:hover {
  border-color: #c0d4c8;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
}

.history-item h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
}

.history-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* ── Toast ── */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #1a5c44;
  color: white;
  padding: 12px 18px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
  animation: slide-in 0.2s ease;
  z-index: 100;
}

@keyframes slide-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Footer ── */

footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 16px 24px 32px;
  line-height: 1.6;
}

footer p { margin: 2px 0; }

.footer-credit {
  font-size: 12px;
  opacity: 0.85;
}

.footer-brand {
  font-weight: 700;
  color: var(--green);
}

/* ── Responsive ── */

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 22px 20px;
  }
  h1 { font-size: 26px; }
  .field-row {
    grid-template-columns: 1fr;
  }
}
