@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');
[hidden] { display: none !important; }

:root {
  --accent: #ff9f1c;
  --accent-dark: #d97f00;
  --ink: #29231d;
  --muted: #8a7d70;
  --bg: #faf6f0;
  --card: #fff;
  --line: #eee4d8;
  --danger: #d92d20;
  --ok: #16803c;
  --radius: 16px;
  --sidebar: #2e241b;
}

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px;
}
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 800; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 700; font-size: 14px; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(150deg, #ffd868, #ff9f24 55%, #ff7d12);
}
.login-card {
  width: min(420px, 100%); background: #fff; border-radius: 24px; padding: 38px;
  box-shadow: 0 24px 70px rgba(120,60,0,.28); text-align: center;
}
.login-logo { width: 70px; height: 70px; margin-bottom: 12px; }
.login-card h1 { font-size: 26px; }
.login-card .muted { margin: 4px 0 26px; }
.login-card label { display: block; text-align: left; margin-bottom: 16px; font-weight: 700; font-size: 13px; }
.login-card label input { margin-top: 6px; }
#login-error { margin-top: 14px; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: none; background: var(--sidebar); color: #f7e9d4;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 24px 22px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-logo { width: 42px; height: 42px; }
.side-brand strong { display: block; font-size: 17px; font-weight: 800; }
.side-brand small { font-size: 11px; color: #c8a97f; letter-spacing: .08em; text-transform: uppercase; font-weight: 800; }
.nav { padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px;
  border: 0; border-radius: 11px; background: transparent; color: #e6d6bf;
  font: inherit; font-weight: 700; cursor: pointer; text-align: left;
}
.nav button:hover { background: rgba(255,255,255,.07); }
.nav button.active { background: var(--accent); color: #3a2400; }
.side-footer { padding: 16px 18px 22px; border-top: 1px solid rgba(255,255,255,.08); }
.side-user { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.side-user small { display: block; color: #c8a97f; font-weight: 600; }
.side-logout { border: 0; background: none; color: #e6b4a0; padding: 8px 0; font: inherit; font-weight: 700; cursor: pointer; font-size: 13px; }

.main-wrap { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 26px 34px 20px; border-bottom: 1px solid var(--line); background: #fff;
}
.topbar p { margin: 4px 0 0; font-size: 13px; }
.content { padding: 28px 34px 60px; max-width: 1240px; }

/* ---------- Général ---------- */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], textarea, select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,159,28,.15); }
textarea { resize: vertical; min-height: 80px; }
label { font-weight: 700; font-size: 13px; }
label input, label select, label textarea { margin-top: 5px; font-weight: 400; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 800;
  cursor: pointer; background: #f1e9de; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); color: #3a2400; box-shadow: 0 6px 14px rgba(255,159,28,.3); }
.btn.danger { background: #ffe6e3; color: #b42318; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.full { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 4px 18px rgba(90,60,30,.05); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.spacer { flex: 1; }

.stat { padding: 20px; }
.stat .value { font-size: 32px; font-weight: 800; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 700; margin-top: 4px; }
.stat .icon { font-size: 22px; float: right; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 800; }
.badge.ok { background: #e4f7ea; color: var(--ok); }
.badge.off { background: #f1eee9; color: #8a7d70; }
.badge.role { background: #fff0d9; color: #996000; }
.empty { text-align: center; padding: 38px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 50; max-width: 380px;
  background: #2e241b; color: #fff; padding: 13px 18px; border-radius: 12px;
  font-weight: 700; box-shadow: 0 12px 30px rgba(0,0,0,.25);
}
.toast.err { background: #b42318; }

/* ---------- Builder ---------- */
.q-card { border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; background: #fffdf9; }
.q-card + .q-card { margin-top: 12px; }
.q-card-head { display: flex; align-items: center; gap: 10px; }
.q-index { width: 28px; height: 28px; flex: none; border-radius: 9px; background: #fff0d9; color: #996000; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.q-card-head input { flex: 1; font-weight: 800; }
.q-actions { display: flex; gap: 4px; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-weight: 800; color: var(--muted); }
.icon-btn:hover { background: #fff3e2; color: var(--ink); }
.icon-btn.del:hover { background: #ffe6e3; color: #b42318; }
.q-meta { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.q-meta > label { flex: 1; min-width: 140px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; flex: none !important; }
.checkbox-label input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.q-card textarea { min-height: 70px; }
.cond { margin-top: 12px; }
.cond label { display: block; }

/* ---------- Réponses ---------- */
.answer-grid { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 8px 18px; }
.answer-grid dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.answer-grid dd { margin: 0; white-space: pre-wrap; }
.response-item { margin-bottom: 12px; }
.response-head { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.response-head::-webkit-details-marker { display: none; }
.response-body { padding: 16px 4px 4px; }

@media (max-width: 860px) {
  .sidebar { width: 72px; }
  .side-brand div, .nav span, .side-user, .side-logout { display: none; }
  .nav button { justify-content: center; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
}
