:root {
  --bg: #f6f4ef;
  --surface: #fff;
  --soft: #fbfaf7;
  --ink: #23211d;
  --muted: #6f6a61;
  --line: #ded9ce;
  --teal: #0f766e;
  --green: #2f7d4e;
  --amber: #b7791f;
  --rose: #b2414a;
  --violet: #6250a4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--teal);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #fffdf9;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.brand-logo {
  display: block;
  width: auto;
  height: 44px;
}

.sidebar .brand {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.brand-login {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.brand-login .brand-logo {
  height: 60px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a,
.button {
  min-height: 38px;
  border-radius: 8px;
}

.nav a {
  display: block;
  padding: 10px 12px;
  color: var(--ink);
}

.nav a:hover,
.nav a.active {
  background: #e8f7f5;
  color: #115e59;
}

.main {
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.panel,
.metric,
.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel,
.login-card {
  padding: 18px;
}

.metric {
  padding: 15px;
  border-top: 4px solid var(--teal);
}

.metric strong {
  display: block;
  font-size: 28px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f2eee5;
  font-size: 12px;
  text-transform: uppercase;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.draft { background: #eee9df; color: #514a3e; }
.sent { background: #e8f1ff; color: #315f9a; }
.reminder_1,
.reminder_2 { background: #fff1d1; color: #855d16; }
.answered { background: #e2f7ee; color: #236542; }
.validated { background: #e8f7f5; color: #115e59; }
.archived { background: #efebf7; color: var(--violet); }
.no_response { background: #ffe6e8; color: var(--rose); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.button.danger {
  border-color: #e8c8c8;
  background: #fff2f2;
  color: var(--rose);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.flash {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: #e8f7f5;
  color: #115e59;
}

.flash.error {
  background: #ffe6e8;
  color: var(--rose);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
}

.form {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.form .actions {
  margin-top: 4px;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

label.checkbox input {
  min-height: auto;
  width: auto;
}

.button.secondary {
  background: var(--soft);
  color: var(--muted);
}

label,
fieldset {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

fieldset {
  grid-column: span 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
}

/* --- Navigation mobile (burger) --- */
.mobile-bar {
  display: none;
}

.nav-overlay {
  display: none;
}

.burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.burger span {
  display: block;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

.mobile-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mobile-brand .brand-mark {
  width: 30px;
  height: 30px;
  font-size: 14px;
}

.mobile-brand .brand-logo {
  height: 30px;
}

@media (max-width: 960px) {
  .layout,
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }

  .grid,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  fieldset {
    grid-column: auto;
  }

  .main {
    padding: 16px;
    min-width: 0;
  }

  /* Barre supérieure mobile avec le burger */
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -16px -16px 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: #fffdf9;
  }

  /* La barre latérale devient un panneau hors-écran */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    max-width: 82vw;
    height: 100vh;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 50;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.15);
  }

  .nav-toggle:checked ~ .sidebar {
    transform: translateX(0);
  }

  .nav-toggle:checked ~ .nav-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
  }

  /* Empêche le défilement de l'arrière-plan quand le menu est ouvert */
  .nav-toggle:checked ~ .main {
    overflow: hidden;
  }
}
