:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --text: #2b2a28;
  --muted: #7a756d;
  --line: #e4ded4;
  --accent: #2f6f5e;
  --accent-soft: #e2efe9;
  --danger: #b4443b;
  --warn-bg: #fff4dc;
  --warn: #9a6a00;
  --busy: #dbe9f6;
  --busy-strong: #3b73a8;
  --cohab: #fde3c8;
  --cohab-strong: #c96a12;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: .2rem 0 .8rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.inline { display: inline; }

/* Barre du haut */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .6rem 1.2rem; background: var(--accent); color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; }
.mainnav { display: flex; flex-wrap: wrap; gap: .2rem; flex: 1; }
.mainnav a { padding: .35rem .7rem; border-radius: 6px; opacity: .85; }
.mainnav a:hover, .mainnav a.active { background: rgba(255,255,255,.18); opacity: 1; }
.usermenu { display: flex; gap: .8rem; align-items: center; font-size: .9rem; }
.linklike { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; font: inherit; text-decoration: underline; }
.topbar .linklike { color: #fff; }
.linklike.danger { color: var(--danger); }

.container { max-width: 1200px; margin: 0 auto; padding: 1.2rem 16px 3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.2rem; }
.card.narrow { max-width: 620px; margin-left: auto; margin-right: auto; }
.pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.pagehead h1, .pagehead h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 1.2rem; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1.2rem; }
@media (max-width: 800px) { .grid-main { grid-template-columns: 1fr; } }

/* Formulaires */
form label { display: block; margin-bottom: .8rem; font-weight: 500; font-size: .92rem; }
input:not([type=checkbox]), select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 1rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
@media (max-width: 560px) { .row2, .row3 { grid-template-columns: 1fr; } }
.filters { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; padding: .7rem 1.1rem; }
.filters label { margin: 0; min-width: 160px; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .8rem; }

.btn {
  display: inline-block; padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text); text-decoration: none; cursor: pointer; font: inherit; font-size: .92rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: #e6c3bf; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash ul { margin: .4rem 0 0; }
.flash-success { background: var(--accent-soft); border-color: #bcd9cd; }
.flash-error { background: #fbe7e5; border-color: #efc1bc; color: #7d2720; }
.flash-warning { background: var(--warn-bg); border-color: #f0d79a; color: #5f4300; }
.flash-info { background: #eaf1f8; border-color: #c8d9ea; }

/* Tableaux */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th.right, .table td.right { text-align: right; }
.table.compact td { padding: .3rem .4rem; }
.table tr.inactive { color: var(--muted); }
.card { overflow-x: auto; }
.pos { color: var(--accent); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
.bigtotal { font-size: 2rem; font-weight: 700; margin: 0; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 99px; background: #efebe4; font-size: .78rem; color: var(--text); text-decoration: none; }
.b-admin { background: var(--accent-soft); }
.b-limited { background: #eee; }
.b-cohab { background: var(--cohab); color: #6a3500; }
.prio-badge-urgente { background: #f7d2ce; color: #7d2720; }
.prio-badge-haute { background: #fde3c8; color: #6a3500; }
.prio-badge-basse { background: #eef0f2; color: #555; }

/* Planning */
.calnav { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.calmonth { margin: 0; min-width: 11rem; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem .8rem; align-items: center; margin-bottom: .8rem; color: var(--muted); }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); vertical-align: middle; }
.lg-free { background: #fff; } .lg-busy { background: var(--busy); } .lg-cohab { background: var(--cohab); }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.calhead { text-align: center; font-weight: 600; font-size: .8rem; color: var(--muted); padding: .2rem; }
.calday { min-height: 88px; border: 1px solid var(--line); border-radius: 6px; padding: 3px; background: #fff; position: relative; overflow: hidden; }
.calday.out { opacity: .45; }
.calday.busy { background: var(--busy); }
.calday.cohab { background: var(--cohab); }
.calday.today { outline: 2px solid var(--accent); }
.daynum { font-size: .8rem; font-weight: 600; color: var(--text); text-decoration: none; }
.cohab-flag { position: absolute; right: 4px; top: 2px; font-size: .8rem; }
.chip { display: block; margin-top: 2px; padding: 0 .35rem; border-radius: 4px; font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: #fff; background: var(--busy-strong); }
span.chip { display: inline-block; }
.chip.st-demandee { background: #fff; color: var(--busy-strong); border: 1px dashed var(--busy-strong); }
.chip.st-confirmee { background: var(--busy-strong); color: #fff; border: 1px solid var(--busy-strong); }
.chip.st-annulee { background: #eee; color: #888; text-decoration: line-through; }
@media (max-width: 600px) { .calday { min-height: 56px; } .chip { font-size: .62rem; } }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); }

/* Tableau de bord */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; text-decoration: none; color: var(--text); }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile-value { font-size: 1.5rem; font-weight: 700; }
.tile-free { border-left: 5px solid var(--accent); }
.tile-busy { border-left: 5px solid var(--busy-strong); background: var(--busy); }
.tile-cohab { border-left: 5px solid var(--cohab-strong); background: var(--cohab); }

/* Travaux */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.column { background: #ece7df; border-radius: var(--radius); padding: .6rem; min-height: 200px; }
.column h2 { font-size: .95rem; display: flex; justify-content: space-between; }
.count { background: #fff; border-radius: 99px; padding: 0 .5rem; font-size: .8rem; }
.ticket { display: block; background: #fff; border-radius: 8px; padding: .55rem .65rem; margin-bottom: .5rem; text-decoration: none; color: var(--text); border-left: 4px solid #bbb; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.ticket:hover { box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.ticket.prio-urgente { border-left-color: var(--danger); }
.ticket.prio-haute { border-left-color: var(--cohab-strong); }
.ticket.prio-normale { border-left-color: var(--busy-strong); }
.ticket-title { font-weight: 600; font-size: .9rem; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: .25rem; margin: .3rem 0 .1rem; }
.description { white-space: pre-wrap; }
.comment { border-top: 1px solid var(--line); padding: .6rem 0; }
.statusform { display: flex; gap: .5rem; align-items: end; margin: 1rem 0; }
.statusform label { flex: 1; margin: 0; }
.badge.col-termine { background: var(--accent-soft); }
.badge.col-en_cours { background: var(--busy); }
.badge.col-abandonne { background: #eee; color: #888; }

/* Galerie */
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.album { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); }
.album img, .nocover { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.nocover { display: flex; align-items: center; justify-content: center; font-size: 3rem; background: #ece7df; }
.album-info { padding: .6rem .8rem; display: flex; flex-direction: column; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.upload { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }
.upload label { flex: 1; min-width: 220px; margin: 0; }
.viewer { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-bottom: 1rem; }
.viewer img { max-width: 100%; max-height: 75vh; border-radius: 8px; display: block; }
.navbtn { font-size: 2.5rem; text-decoration: none; min-width: 2rem; text-align: center; }
.caption { font-size: 1.1rem; }

/* Options du planning : capacité et périodes prioritaires */
.calday.over { box-shadow: inset 0 0 0 2px var(--danger); }
.guests { display: block; font-size: .7rem; color: var(--muted); }
.guests.over { color: var(--danger); font-weight: 700; }
.prio-band { display: block; font-size: .68rem; color: #6b4e00; background: #fbe9a6; border-radius: 3px; padding: 0 .25rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prio-band.static { display: inline-block; }

/* Paramètres et caisse */
.section-title { display: flex; align-items: center; gap: .6rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.inline-form label { margin: 0; flex: 1; min-width: 140px; }
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .4rem .9rem; border-radius: 6px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Mode test (démonstration) */
.demo-banner { background: #fde68a; color: #5f4300; text-align: center; padding: .35rem 1rem; font-size: .9rem; font-weight: 600; }
