:root {
  --ink: #14251c;
  --muted: #5b6d63;
  --green: #1f7a4c;
  --green-deep: #0f3d2a;
  --gold: #c9a227;
  --sand: #f3efe4;
  --paper: #fffdf8;
  --line: rgba(20, 37, 28, 0.1);
  --low: #9b2c2c;
  --mid: #b7791f;
  --good: #1f7a4c;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(15, 61, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Source Sans 3", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(201, 162, 39, 0.16), transparent 50%),
    linear-gradient(180deg, #eef4ee 0%, var(--sand) 40%, #e7efe6 100%);
}

a { color: var(--green-deep); }
h1, h2, h3 {
  font-family: "Fraunces", serif;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 0.88rem; margin: 1rem 0 0.5rem; color: var(--muted); font-family: "Source Sans 3", sans-serif; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--green-deep);
  color: #f6f1e4;
  padding: 1.6rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { color: inherit; text-decoration: none; display: grid; gap: 0.15rem; }
.brand-mark {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--gold);
  font-weight: 700;
}
.brand-title { font-family: "Fraunces", serif; font-size: 1.6rem; }
.brand-sub { font-size: 0.88rem; opacity: 0.8; }

.nav { display: grid; gap: 0.25rem; }
.nav a {
  color: inherit;
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  opacity: 0.82;
}
.nav a:hover, .nav a.is-active {
  background: rgba(255,255,255,0.08);
  opacity: 1;
}

.cta {
  margin-top: auto;
  display: block;
  text-align: center;
  background: var(--gold);
  color: var(--green-deep);
  text-decoration: none;
  font-weight: 700;
  padding: 0.75rem 0.9rem;
  border-radius: 999px;
}
.sidebar-note { font-size: 0.78rem; opacity: 0.7; margin: 0; }
.sidebar-account {
  margin-top: auto;
  display: grid;
  gap: 0.7rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(246, 241, 228, 0.16);
}
.sidebar-user { margin: 0; display: grid; gap: 0.1rem; }
.sidebar-user-name { font-weight: 700; font-size: 0.95rem; }
.sidebar-user-id { font-size: 0.78rem; opacity: 0.7; }
.logout-form { margin: 0; }
.logout-form button {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(246, 241, 228, 0.28);
  color: #f6f1e4;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  opacity: 0.82;
}
.logout-form button:hover { opacity: 1; background: rgba(255,255,255,0.08); }
.topbar-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-shell { width: min(420px, 100%); }
.login-card {
  background: var(--paper);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2rem 1.7rem 1.8rem;
}
.login-card h1 {
  font-size: 2rem;
  margin: 0.15rem 0 0.35rem;
}
.login-sub { margin: 0 0 1.2rem; color: var(--muted); }
.login-form { display: grid; gap: 0.9rem; }
.login-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.login-form input {
  font: inherit;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  color: var(--ink);
}
.login-form input:focus {
  outline: 2px solid rgba(31, 122, 76, 0.28);
  border-color: var(--green);
}
.login-form .btn { width: 100%; margin-top: 0.3rem; padding: 0.8rem 1rem; }
.login-form .errorlist { list-style: none; padding: 0; margin: 0; color: var(--low); font-size: 0.8rem; font-weight: 500; }

.main { padding: 1.6rem 2rem 3rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.2rem;
}
.kicker {
  margin: 0 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.pill.ok { background: #d9efe3; color: var(--green-deep); }
.pill.warn { background: #f7e7c6; color: #7a5410; }

.banner, .flash, .lede, .muted { color: var(--muted); }
.banner, .flash {
  background: #fff6df;
  border: 1px solid #ead7a0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
}
.flash.error, .flash.error { background: #fdecec; border-color: #f0b4b4; color: #7b1e1e; }
.flash.success { background: #e7f6ee; border-color: #b7e0c8; color: var(--green-deep); }
.lede { margin: 0 0 1rem; }
.tiny { font-size: 0.8rem; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  background: var(--paper);
  padding: 0.9rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
  align-items: end;
}
.filters label { display: grid; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.filters select, .btn, pre {
  font: inherit;
}
.filters select {
  min-width: 150px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--green-deep);
  border: 1px solid var(--line);
}

.kpis, .grid-2, .grid-3 {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}
.kpis { grid-template-columns: repeat(4, 1fr); }
.kpis-6 { grid-template-columns: repeat(3, 1fr); }
.kpis-niveaux { grid-template-columns: 1fr 1fr; }
.grid-2 { grid-template-columns: 1.15fr 0.85fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.kpi, .card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
}
.kpi-label, .kpi-hint { margin: 0; color: var(--muted); }
.kpi-label { font-size: 0.82rem; font-weight: 600; }
.kpi-value {
  font-family: "Fraunces", serif;
  font-size: 2.2rem;
  margin: 0.15rem 0;
}
.kpi-unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: 0.15rem;
}
.kpi .bar { margin-top: 0.7rem; }
.theme-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.1rem; }
.theme-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: baseline;
}
.theme-meta { margin: 0.15rem 0 0.4rem; font-size: 0.88rem; }
.kpi-inline { display: flex; justify-content: space-between; align-items: baseline; }

.good { color: var(--good); }
.mid { color: var(--mid); }
.low { color: var(--low); }
.muted { color: var(--muted); }

.chart-wrap { height: 320px; position: relative; }
.chart-wrap.tall { height: 380px; }
.chart-wrap canvas { max-height: 100%; }

.score-list, .rank-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.score-list li, .dist {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.8rem;
  align-items: center;
}
.score-list .bar, .dist .bar { grid-column: 1 / -1; }
.bar {
  height: 8px;
  background: rgba(20,37,28,0.08);
  border-radius: 99px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #49a36f);
  border-radius: inherit;
}

.extreme-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.85rem; }
.extreme-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.8rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.extreme-list p, .extreme-list em { margin: 0.15rem 0 0; }
.extreme-list em { font-style: normal; font-weight: 700; white-space: nowrap; }
.rank-list.compact li { padding-bottom: 0.4rem; }
.card blockquote { box-shadow: none; margin-bottom: 0.6rem; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.65rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.tabs, .chip-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tab, .chip {
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 0.88rem;
}
.tab.is-active, .chip.is-active {
  background: var(--green-deep);
  color: #fff;
  border-color: transparent;
}

.stack-block { margin-bottom: 0.9rem; }
.stack-block p { margin: 0 0 0.3rem; font-size: 0.9rem; }
.stack { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: rgba(20,37,28,0.06); }
.seg { min-width: 2px; }
.s1 { background: #9b2c2c; }
.s2 { background: #c05621; }
.s3 { background: #d69e2e; }
.s4 { background: #38a169; }
.s5 { background: #1a5d3a; }
.s6 { background: #718096; }
.legend { display: flex; flex-wrap: wrap; gap: 0.7rem 1rem; list-style: none; padding: 0; font-size: 0.8rem; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 0.35rem; }

.rank-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}
.rank-n {
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  background: var(--sand);
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.8rem;
}
.rank-list p { margin: 0; }
.rank-list em { font-style: normal; font-weight: 700; color: var(--green); }

.quotes { display: grid; gap: 0.8rem; }
blockquote {
  margin: 0;
  background: var(--paper);
  border-left: 4px solid var(--gold);
  padding: 0.9rem 1rem;
  border-radius: 0 14px 14px 0;
  box-shadow: var(--shadow);
}

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.toolbar-actions { display: flex; gap: 0.5rem; }
.dl { display: grid; gap: 0.7rem; }
.dl div { display: grid; grid-template-columns: 180px 1fr; gap: 0.6rem; }
dt { color: var(--muted); }
dd { margin: 0; }
pre {
  background: #14251c;
  color: #e9f4ec;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  overflow: auto;
}
.steps { padding-left: 1.1rem; line-height: 1.55; }
.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }

.stack-form p { display: grid; gap: 0.3rem; margin: 0 0 0.9rem; }
.stack-form label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.input, .stack-form input[type="text"], .stack-form input[type="email"],
.stack-form input[type="password"], .stack-form select, .stack-form textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font: inherit;
  background: #fff;
}
.stack-form p:has(> input[type="checkbox"]) {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}
.stack-form input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--green-deep); }
.stack-form.form-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1.1rem; }
.stack-form.form-3 > .btn, .stack-form.form-3 > a { align-self: end; margin-bottom: 0.9rem; }
.stack-form p:has(#id_pages),
.stack-form p:has(#id_administrateur) {
  grid-column: 1 / -1;
}
.stack-form p:has(#id_pages) {
  display: grid;
}
.stack-form ul {
  list-style: none;
  padding: 0;
  margin: 0.2rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.35rem 1rem;
}
.stack-form ul label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  color: var(--ink);
}
.report-parts {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 0.45rem;
}
.report-parts label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--ink);
}
.stack-form .helptext, .stack-form .helptext ul { margin: 0; font-size: 0.78rem; color: var(--muted); font-weight: 400; }
.stack-form .errorlist { list-style: none; padding: 0; margin: 0; color: var(--low); font-size: 0.82rem; }
.actions { display: flex; gap: 0.65rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
button.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--green-deep);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
button.linkish.danger { color: var(--low); }

@media (max-width: 1100px) {
  .kpis, .kpis-6, .kpis-niveaux, .grid-2, .grid-3, .stack-form.form-3 { grid-template-columns: 1fr 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: relative; }
}
@media (max-width: 740px) {
  .kpis, .kpis-6, .kpis-niveaux, .grid-2, .grid-3, .dl div, .stack-form.form-3 { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}
