@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --green: #1B5E3B;
  --green-light: #2E7D54;
  --navy: #0D1F2D;
  --cream: #F5F2EC;
  --accent: #7EC8A0;
  --border: #DCE3DC;
  --border-strong: #C3CFC5;
  --text: #1a1a1a;
  --muted: #6b7a72;
  --danger: #B3261E;
  --danger-bg: #FBEAE9;
  --warn: #8A5A00;
  --warn-bg: #FCF1D8;
  --ok: #1B5E3B;
  --ok-bg: #E6F1EA;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  line-height: 1.5;
}
h1, h2, h3 { font-family: 'DM Serif Display', serif; font-weight: 400; margin: 0; }
a { color: var(--green); }

.topbar {
  background: var(--navy);
  color: white;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar .badge {
  width: 38px; height: 38px; border-radius: 8px;
  background: white; color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; overflow: hidden; padding: 3px;
}
.badge img, .profile-logo img, .fiche-logo img, .brand-badge img {
  width: 100%; height: 100%; object-fit: contain;
}
.topbar h1 { font-size: 18px; color: white; }
.topbar .sub { font-size: 12px; color: var(--accent); margin-top: 2px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: #D9E6DD; }
.topbar a.logout { font-size: 12px; color: #D9E6DD; text-decoration: none; border: 1px solid rgba(255,255,255,0.25); padding: 6px 12px; border-radius: 6px; }
.topbar a.logout:hover { background: rgba(255,255,255,0.08); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 32px 60px; }
.wrap.narrow { max-width: 480px; }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel] {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border-strong); border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 14px; background: var(--cream); outline: none;
}
input:focus { border-color: var(--green); }

button, .btn {
  font-family: 'DM Sans', sans-serif; font-size: 13px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: white; color: var(--text);
  padding: 8px 14px; border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--green); }
.btn-primary { background: var(--navy); color: white; border-color: var(--navy); }
.btn-primary:hover { background: #14293a; }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

.tag { font-size: 11px; padding: 3px 9px; border-radius: 20px; font-weight: 500; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-neutral { background: var(--cream); color: var(--muted); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 12px; background: var(--cream); }
td { padding: 10px 12px; border-top: 1px solid var(--border); }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; }
.stat { background: var(--cream); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 22px; font-weight: 500; font-family: 'DM Sans', sans-serif; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 3px; }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin: 20px 0 0; }
.tab { padding: 10px 0; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--green); border-color: var(--green); font-weight: 500; }
.tab-panel { display: none; padding-top: 18px; }
.tab-panel.active { display: block; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

.notif { padding: 10px 0; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.notif:first-child { border-top: none; }

.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); font-size: 12px; }
.dropzone i { font-size: 20px; display: block; margin-bottom: 6px; }
.hint { font-size: 11px; color: var(--muted); margin: 6px 0 0; }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* Barre de navigation, style site ASPEM */
.site-nav {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.site-nav .logo-link { display: flex; align-items: center; }
.site-nav .logo-link img { height: 34px; }
.site-nav .nav-links { display: flex; gap: 22px; flex: 1; }
.site-nav .nav-links a {
  color: var(--green);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.site-nav .nav-links a:hover { text-decoration: underline; }
.site-nav .nav-links a.current { color: var(--navy); font-weight: 700; }
.site-nav .btn-pill {
  background: var(--green);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav .btn-pill:hover { background: var(--green-light); }
@media (max-width: 800px) {
  .site-nav { flex-wrap: wrap; gap: 12px; }
  .site-nav .nav-links { flex-basis: 100%; order: 3; flex-wrap: wrap; gap: 14px; }
}

/* ===== Menu déroulant Back-office ===== */
.site-nav .dropdown { position: relative; }
.site-nav .dropdown::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 14px; }
.site-nav .dd-btn { background: none; border: none; padding: 0; font-family: inherit; font-size: 14px; font-weight: 500; color: var(--green); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.site-nav .dd-btn:hover { border: none; text-decoration: underline; }
.site-nav .dd-btn.current { color: var(--navy); font-weight: 700; }
.site-nav .dd-menu { display: none; position: absolute; top: 100%; left: -10px; margin-top: 12px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(13,31,45,.12); min-width: 250px; padding: 6px; z-index: 60; flex-direction: column; }
.site-nav .dropdown:hover .dd-menu, .site-nav .dropdown.open .dd-menu, .site-nav .dropdown:focus-within .dd-menu { display: flex; }
.site-nav .dd-menu a { display: block; padding: 9px 12px; border-radius: 6px; font-size: 13px; text-decoration: none; }
.site-nav .dd-menu a:hover { background: var(--cream); text-decoration: none; }
.site-nav .dd-menu a.current { background: var(--ok-bg); color: var(--navy); font-weight: 600; }

/* ===== Sous-navigation back-office, en-têtes, puces ===== */
.subnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.subnav a { font-size: 13px; color: var(--muted); text-decoration: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; }
.subnav a:hover { border-color: var(--green); color: var(--green); }
.subnav a.current { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { font-size: 26px; }
.page-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.session-row { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.session-row a { color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 5px 12px; border-radius: 999px; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0 12px; }
.toolbar input[type=text], .toolbar select { max-width: 280px; }
select { font-family: inherit; font-size: 13px; padding: 8px 10px; border: 1.5px solid var(--border-strong); border-radius: 8px; background: var(--cream); }
.callout { border: 1px solid var(--border-strong); border-left: 4px solid var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 12px 14px; font-size: 13px; }
.callout.info { border-left-color: var(--green); background: var(--ok-bg); }
.callout strong { font-weight: 600; }
.progress { height: 8px; background: var(--cream); border-radius: 99px; overflow: hidden; margin-top: 10px; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.scroll-box { max-height: 520px; overflow: auto; }
.scroll-box th { position: sticky; top: 0; z-index: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-soc { display: flex; align-items: center; gap: 10px; }
.row-soc img.row-logo-img { width: 28px; height: 28px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; padding: 3px; background: #fff; }
.initials { width: 28px; height: 28px; border-radius: 6px; background: var(--ok-bg); color: var(--green); display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin: 0; }
.checks input { width: auto; }

/* ===== Page société : bannière et logo modifiables ===== */
.card-nopad { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.banner { position: relative; width: 100%; aspect-ratio: 5 / 1; background: linear-gradient(90deg, var(--green), var(--navy)); background-size: cover; background-position: center; }
.edit-banner { position: absolute; right: 12px; bottom: 12px; background: rgba(255,255,255,.95); border-color: transparent; font-size: 12px; padding: 6px 12px; border-radius: 999px; }
.profile-head { display: flex; align-items: flex-end; gap: 16px; padding: 0 22px; margin-top: -34px; position: relative; }
.profile-logo-wrap { position: relative; flex-shrink: 0; }
.profile-logo { width: 76px; height: 76px; border-radius: 14px; background: #fff; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.14); display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 6px; box-sizing: border-box; }
.profile-logo img { width: 100%; height: 100%; object-fit: contain; }
.profile-logo .initials { width: 100%; height: 100%; font-size: 18px; border-radius: 8px; }
.edit-logo { position: absolute; right: -6px; bottom: -6px; width: 28px; height: 28px; padding: 0; border-radius: 50%; justify-content: center; background: var(--navy); color: #fff; border-color: #fff; font-size: 14px; }
.edit-logo:hover { background: var(--green); border-color: #fff; }
.profile-meta { flex: 1; padding-bottom: 8px; min-width: 0; }
.profile-name { font-size: 17px; font-weight: 600; margin: 0; }
.profile-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: #d99a00; } .dot.danger { background: var(--danger); }

/* ===== Recadrage d'image ===== */
.crop-overlay { position: fixed; inset: 0; background: rgba(13,31,45,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.crop-modal { background: #fff; border-radius: 14px; padding: 22px; max-width: 100%; max-height: 100%; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.crop-modal h3 { font-size: 20px; }
.crop-viewport { position: relative; overflow: hidden; background: #e4e8e4; border-radius: 8px; cursor: grab; touch-action: none; margin: 0 auto; outline-offset: 3px; }
.crop-viewport.grabbing { cursor: grabbing; }
.crop-img { position: absolute; max-width: none; user-select: none; pointer-events: none; }
.crop-grid { position: absolute; inset: 0; pointer-events: none; border: 2px solid rgba(255,255,255,.9); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
  background-image: linear-gradient(to right, transparent 33.2%, rgba(255,255,255,.55) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.55) 66.6%, transparent 66.8%),
                    linear-gradient(to bottom, transparent 33.2%, rgba(255,255,255,.55) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.55) 66.6%, transparent 66.8%); }
.crop-controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; color: var(--muted); }
.crop-controls input[type=range] { width: 220px; padding: 0; accent-color: var(--green); }
.crop-warn { margin: 10px 0 0; font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 6px; padding: 8px 10px; }
.crop-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Zone de dépôt (formulaire d'ajout) */
.dropzone { cursor: pointer; position: relative; overflow: hidden; }
.dropzone:hover { border-color: var(--green); }
.dropzone img.preview { display: block; width: 100%; height: auto; border-radius: 6px; }
.dropzone.has-img { padding: 6px; border-style: solid; }

/* Corrections : cartes de stats (la classe .num sert aussi aux tableaux) et titre du profil */
.stat .num { text-align: left; white-space: normal; }
.profile-head { align-items: flex-start; }
.profile-meta { padding: 40px 0 8px; }
.ico { flex-shrink: 0; }
.edit-banner { display: inline-flex; align-items: center; gap: 6px; }
.edit-banner { z-index: 5; }

/* ===== Impression : état de caisse ===== */
.print-only { display: none; }
@media print {
  body.print-etat .site-nav, body.print-etat .subnav, body.print-etat .session-row, body.print-etat .page-head,
  body.print-etat .tabs, body.print-etat .tab-panel:not(#etat), body.print-etat .no-print, body.print-etat #imp, body.print-etat .toast { display: none !important; }
  body.print-etat { background: #fff; }
  body.print-etat .wrap { max-width: none; padding: 0; }
  body.print-etat #etat { display: block !important; padding-top: 0; }
  body.print-etat .print-only { display: block; }
  body.print-etat .stat { border: 1px solid #ccc; }
}
