/* Charte LCDC — charcoal / crème / sable / taupe, angles nets, sobriété. */

:root {
  --charcoal: #3a3733;
  --cream: #faf6f0;
  --sand: #f5f1e9;
  --taupe: #8a7f6f;
  --line: #e2dad0;
  --line-strong: #cfc5b6;
  --white: #ffffff;

  --st-validee: #5c7d5e;
  --st-debattre: #b8863f;
  --st-idee: #8a7f6f;
  --st-reportee: #5a7183;
  --st-rejetee: #a85449;

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 400;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin: 0 0 0.4em;
}

h1 { font-size: 30px; line-height: 1.2; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

a { color: var(--charcoal); text-decoration: none; border-bottom: 1px solid var(--line-strong); }
a:hover { border-bottom-color: var(--charcoal); }

/* ---------- Structure ---------- */

.site-header {
  background: var(--charcoal);
  color: var(--cream);
  border-bottom: 1px solid var(--charcoal);
}

.site-header .inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 58px;
}

.brand {
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cream);
  border: 0;
  white-space: nowrap;
}
.brand span { color: var(--taupe); }

.site-nav { display: flex; gap: 22px; flex: 1; flex-wrap: wrap; }
.site-nav a {
  color: #d9d0c4;
  border: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--cream); }
.site-nav a.active { color: var(--cream); border-bottom-color: var(--taupe); }

.site-user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #d9d0c4; }

main { max-width: 1400px; margin: 0 auto; padding: 28px 24px 64px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head p.lede { margin: 0; color: var(--taupe); font-size: 13px; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 20px 22px;
}
.panel + .panel { margin-top: 18px; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-block;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 9px 16px;
  border: 1px solid var(--charcoal);
  background: var(--charcoal);
  color: var(--cream);
  cursor: pointer;
  border-radius: 0;
}
.btn:hover { background: #2c2926; border-bottom-color: #2c2926; }
.btn.ghost { background: transparent; color: var(--charcoal); }
.btn.ghost:hover { background: var(--sand); }
.btn.small { padding: 5px 10px; font-size: 11px; }
.btn.link {
  background: none;
  border: 0;
  color: var(--taupe);
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  padding: 2px 4px;
}
.btn.link:hover { color: var(--charcoal); background: none; text-decoration: underline; }
.btn.danger { border-color: var(--st-rejetee); color: var(--st-rejetee); background: none; }
.btn.danger:hover { background: rgba(168, 84, 73, 0.08); }

/* ---------- Formulaires ---------- */

label { display: block; font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--taupe); margin-bottom: 5px; }

input[type="text"],
input[type="search"],
input[type="password"],
select,
textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--charcoal);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 8px 10px;
}
textarea { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--taupe); outline-offset: -1px; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-row { margin-bottom: 16px; }

/* ---------- Compteurs de statut ---------- */

.counters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.counter {
  border: 1px solid var(--line);
  background: var(--white);
  padding: 10px 16px;
  min-width: 118px;
  border-bottom: 3px solid var(--line-strong);
}
.counter:hover { background: var(--sand); }
.counter .num { font-family: var(--serif); font-size: 26px; line-height: 1; display: block; }
.counter .lbl { font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--taupe); }
.counter.is-active { background: var(--sand); }
.counter[data-status="validee"] { border-bottom-color: var(--st-validee); }
.counter[data-status="debattre"] { border-bottom-color: var(--st-debattre); }
.counter[data-status="idee"] { border-bottom-color: var(--st-idee); }
.counter[data-status="reportee"] { border-bottom-color: var(--st-reportee); }
.counter[data-status="rejetee"] { border-bottom-color: var(--st-rejetee); }
.counter[data-status="total"] { border-bottom-color: var(--charcoal); }
a.counter { border-bottom-style: solid; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge.status-validee { color: var(--st-validee); background: rgba(92, 125, 94, 0.09); }
.badge.status-debattre { color: var(--st-debattre); background: rgba(184, 134, 63, 0.10); }
.badge.status-idee { color: var(--st-idee); background: rgba(138, 127, 111, 0.10); }
.badge.status-reportee { color: var(--st-reportee); background: rgba(90, 113, 131, 0.10); }
.badge.status-rejetee { color: var(--st-rejetee); background: rgba(168, 84, 73, 0.09); }
.badge.prio { color: var(--taupe); background: var(--sand); border-color: var(--line-strong); }

/* ---------- Filtres ---------- */

.filters {
  display: grid;
  grid-template-columns: 2fr 1.3fr 1.3fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  background: var(--white);
  border: 1px solid var(--line);
  padding: 16px 18px;
  margin-bottom: 16px;
}
@media (max-width: 1000px) { .filters { grid-template-columns: 1fr 1fr; } }

/* ---------- Tableau ---------- */

.table-wrap { border: 1px solid var(--line); background: var(--white); overflow-x: auto; }

table.features { width: 100%; border-collapse: collapse; font-size: 13px; }
table.features thead th {
  background: var(--sand);
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--taupe);
  font-weight: 500;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-strong);
  position: sticky;
  top: 0;
  z-index: 1;
}
table.features tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.features tbody tr:hover { background: var(--sand); }
table.features td.fid { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--taupe); }
table.features td.title a { border-bottom: 0; font-weight: 500; }
table.features td.title a:hover { border-bottom: 1px solid var(--charcoal); }
table.features td.module { color: var(--taupe); white-space: nowrap; }

.result-count { font-size: 12px; color: var(--taupe); padding: 10px 14px; border-top: 1px solid var(--line); }
.empty { padding: 40px; text-align: center; color: var(--taupe); }

/* ---------- Fiche ---------- */

.feature-head { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.feature-head .fid { font-family: var(--serif); font-size: 26px; color: var(--taupe); }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin: 18px 0;
}
.meta-cell { background: var(--white); padding: 12px 14px; }
.meta-cell .k { font-size: 11px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--taupe); display: block; margin-bottom: 4px; }
.meta-cell .v { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 24px; }
.edit-pencil { opacity: 0; transition: opacity .12s; }
.meta-cell:hover .edit-pencil, .editable:hover .edit-pencil { opacity: 1; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); margin: 24px 0 0; }
.tab {
  background: none;
  border: 1px solid transparent;
  border-bottom: 0;
  padding: 9px 18px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--taupe);
  cursor: pointer;
}
.tab.active { background: var(--white); border-color: var(--line-strong); color: var(--charcoal); margin-bottom: -1px; }
.tab-panel { background: var(--white); border: 1px solid var(--line-strong); border-top: 0; padding: 22px 24px; }

/* ---------- Markdown ---------- */

.markdown { font-size: 14.5px; line-height: 1.65; max-width: 74ch; }
.markdown h1, .markdown h2, .markdown h3 { margin-top: 1.2em; }
.markdown h2 { font-size: 20px; }
.markdown h3 { font-size: 17px; }
.markdown ul, .markdown ol { padding-left: 22px; }
.markdown li { margin-bottom: 4px; }
.markdown code { background: var(--sand); padding: 1px 5px; font-size: 0.9em; }
.markdown pre { background: var(--sand); padding: 12px 14px; overflow-x: auto; border-left: 2px solid var(--taupe); }
.markdown blockquote { border-left: 2px solid var(--taupe); margin: 0; padding-left: 14px; color: var(--taupe); }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--line-strong); padding: 6px 10px; }

/* ---------- Historique / commentaires ---------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-size: 12px; color: var(--taupe); }
.timeline .who { font-weight: 500; }
.diff { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: baseline; margin-top: 6px; font-size: 13px; }
.diff .old { color: var(--st-rejetee); text-decoration: line-through; }
.diff .arrow { color: var(--taupe); }
.diff .new { color: var(--st-validee); }
@media (max-width: 700px) { .diff { grid-template-columns: 1fr; } .diff .arrow { display: none; } }

.comment { border-left: 2px solid var(--line-strong); padding: 4px 0 4px 14px; margin-bottom: 16px; }
.comment .head { display: flex; gap: 10px; align-items: baseline; }
.comment .body { white-space: pre-wrap; margin-top: 4px; }

/* ---------- Divers ---------- */

.flash { padding: 10px 14px; border: 1px solid var(--line-strong); background: var(--sand); font-size: 13px; }
.flash-error { border-color: var(--st-rejetee); color: var(--st-rejetee); background: rgba(168, 84, 73, 0.06); }

.login-wrap { max-width: 380px; margin: 90px auto; }
.login-wrap .brand-block { text-align: center; margin-bottom: 28px; }
.login-wrap .brand-block .title { font-family: var(--serif); font-size: 34px; letter-spacing: 0.04em; }
.login-wrap .brand-block .sub { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--taupe); }

[x-cloak] { display: none !important; }

.muted { color: var(--taupe); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 14px; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity .2s; font-size: 12px; color: var(--taupe); }

.export-card { border: 1px solid var(--line); background: var(--white); padding: 20px 22px; }
.export-card + .export-card { margin-top: 14px; }
.export-card h3 { margin-bottom: 6px; }
.export-card p { margin: 0 0 14px; color: var(--taupe); font-size: 13px; }
