:root {
  --green: #0b7a55;
  --green-dark: #075c40;
  --green-soft: #e3f3ec;
  --orange: #ff7a1a;
  --ground: #dfe9e4;
  --ink: #13201b;
  --muted: #4a5a53;
  --line: #e3ebe7;
  --border: #d3ddd8;
  --danger: #b42318;
  --danger-line: #f1cdc8;
  --pending: #a14a06;
  --pending-bg: #fef3e2;
  --glass: rgba(255, 255, 255, .88);
  --shadow: 0 10px 30px rgba(15, 40, 30, .14);
  --radius: 4px;
  --font: 'Geist', system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--ground);
}

a { color: var(--green); }
a:hover { color: var(--green-dark); }
code, pre { font-family: var(--mono); }
h1 { margin: 0; font-size: 20px; font-weight: 700; }
h2 { margin: 0; font-size: 16px; font-weight: 700; }
[hidden] { display: none !important; }

.muted { color: var(--muted); font-size: 13px; font-weight: 400; }
.error { margin: 0; color: var(--danger); font-size: 13px; }

/* Carte en fond, interface par-dessus */

.map { position: fixed; inset: 0; z-index: 0; background: var(--ground); }

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
  pointer-events: none;
}
.shell > * { pointer-events: auto; }
.view { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; pointer-events: none; }
.view > * { pointer-events: auto; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* En-tête */

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 8px 10px 8px 18px; }
.brand { font-size: 17px; font-weight: 700; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.nav a { padding: 7px 12px; border-radius: var(--radius); color: var(--muted); font-weight: 600; text-decoration: none; }
.nav a.active { background: var(--green-soft); color: var(--green); }
.search .input { min-width: 200px; }
.user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

/* Contrôles */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { color: var(--ink); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { color: var(--danger); border-color: var(--danger); }
.link { padding: 0; border: 0; background: none; color: var(--green); font: inherit; text-decoration: underline; cursor: pointer; }
.push { margin-left: auto; }

.input {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
}
textarea.input { padding: 8px 10px; resize: vertical; }
input[type=file] { font: inherit; font-size: 13px; font-weight: 400; color: var(--muted); }
input[type=file]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.input-small { min-height: 32px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field-error { color: var(--danger); font-weight: 400; }
.field-error:empty { display: none; }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; font-weight: 400; }
.check input, .role input { accent-color: var(--green); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1 1 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--radius); font-size: 11px; font-weight: 700; background: var(--line); color: var(--muted); }
.badge-pending { background: var(--pending-bg); color: var(--pending); }
.badge-published, .badge-yes { background: var(--green-soft); color: var(--green-dark); }
.badge-rejected { background: #fdecea; color: var(--danger); }
.badge-admin { background: var(--ink); color: #fff; }

.segmented { display: flex; gap: 3px; padding: 3px; border-radius: var(--radius); background: #eef3f0; }
.segmented button { flex: 1; min-height: 32px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* Panneaux */

.panel { display: flex; flex-direction: column; gap: 14px; width: 100%; padding: 18px; }
.panel-list { max-width: 440px; padding: 0; gap: 0; }
.panel-list > .panel-head, .panel-list > .segmented, .panel-list > .filters { margin: 18px 18px 0; }
.panel-list > .filters { margin-bottom: 14px; }
.panel-form { max-width: 440px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 8px; }
.filters select { flex: 1 1 auto; }
.back { font-size: 13px; text-decoration: none; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.fields { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.fields:empty { display: none; }
.panel-form > .actions { padding-top: 12px; border-top: 1px solid var(--line); }

.items { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.item { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item.selected { background: rgba(11, 122, 85, .07); }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.item-head strong { flex: 1 1 auto; font-size: 15px; }
.item .actions .btn-primary { margin-left: auto; }
.empty { margin: 0; padding: 18px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; }

.columns { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; width: 100%; }
.panel-main { flex: 999 1 560px; min-width: 0; padding: 0; gap: 0; }
.panel-main > .panel-head, .panel-main > p { margin: 18px 18px 0; }
.panel-main > .table-wrap { margin-top: 14px; }
.panel-main > .error { margin: 0 18px 18px; }
.panel-side { flex: 1 1 340px; min-width: 0; }
.panel-code { padding: 0; gap: 0; overflow: hidden; }
.panel-code pre { max-height: calc(100vh - 180px); margin: 0; padding: 16px; font-size: 12px; line-height: 1.6; overflow: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
th { font-size: 12px; font-weight: 600; color: var(--muted); }
td code { font-size: 12px; color: var(--muted); }
tbody tr.selected { background: rgba(11, 122, 85, .07); }
tbody tr[data-selectable] { cursor: pointer; }
.cell-actions { text-align: right; white-space: nowrap; }

.roles, .choices { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; }
.roles legend, .choices legend { margin-bottom: 6px; padding: 0; font-size: 13px; font-weight: 600; }
.choices-list { display: flex; flex-direction: column; }
.choices-list .check { min-height: 30px; }
.role { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer; }
.role:has(input:checked) { border-color: var(--green); }
.invite-link { display: flex; flex-direction: column; gap: 6px; }
.invite-link .row > .input { flex: 1 1 auto; }
.invite-link .row > .btn { flex: 0 0 auto; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 72px; height: 72px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }
.thumb-remove { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: var(--radius); background: rgba(19, 32, 27, .75); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }

/* Connexion */

.view:has(.card-auth) { align-items: center; justify-content: center; min-height: calc(100vh - 32px); }
.card-auth { display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 380px; padding: 28px; }
.card-title { display: flex; flex-direction: column; gap: 4px; }
.card-title .brand { font-size: 20px; }

.error-panel { max-width: 440px; margin: 0; color: var(--danger); }

/* Repères Leaflet */

.pin { width: 14px; height: 14px; border-radius: 50%; background: var(--green); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.pin-on { width: 22px; height: 22px; background: var(--orange); box-shadow: 0 0 0 8px rgba(255, 122, 26, .22); }
.leaflet-container { font-family: var(--font); }

@media (max-width: 640px) {
  .shell { padding: 8px; }
  .search .input { min-width: 0; width: 100%; }
  .search { flex: 1 1 100%; }
}
