/* Administration */
:root {
  --accent: #46607a; --ink: #1f2933; --muted: #64707d; --bg: #f3f5f8; --card: #fff; --line: #dde3ea;
  --ok: #2f855a; --ko: #c53030; --warn: #b7791f; --info: #2b6cb0;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .strong { font-weight: 600; }
code { background: #e9eef3; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

input, select, textarea, button { font: inherit; }
input:not([type=checkbox]):not([type=color]):not([type=file]), select, textarea {
  padding: 7px 9px; border: 1px solid #c5ced8; border-radius: 7px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
label { display: block; font-size: .9rem; }
label > input:not([type=checkbox]), label > select, label > textarea { margin-top: 4px; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--card); color: var(--accent); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.btn.danger { border-color: var(--ko); color: var(--ko); }
.btn.small { padding: 5px 9px; font-size: .85rem; }
.btn:hover { filter: brightness(.96); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: .9rem; }
.linkbtn.danger { color: var(--ko); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--accent); color: #fff; }
.topbar a { color: #fff; }
.brand { font-weight: 700; text-decoration: none; display: flex; align-items: baseline; gap: 8px; }
.brand small { font-weight: 400; opacity: .8; }
.usernav { display: flex; align-items: center; gap: 16px; font-size: .9rem; }
.usernav form { margin: 0; } .usernav .linkbtn { color: #fff; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 48px); }
.sidenav { padding: 16px 10px; border-right: 1px solid var(--line); background: #f8fafc; }
.sidenav a { display: block; padding: 8px 12px; border-radius: 7px; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.sidenav a:hover { background: #e9eef3; }
.sidenav a.active { background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent); font-weight: 600; }
.content { padding: 24px; min-width: 0; }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid; margin: 0 0 12px; }
.alert.ok { background: #effaf3; border-color: #b6e2c6; }
.alert.ko { background: #fdf0f0; border-color: #f2c1c1; }
.alert.warn { background: #fff8e6; border-color: #f1d79b; }
.alerts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 4px; }
.alerts li { padding: 6px 10px 6px 30px; border-radius: 7px; position: relative; font-size: .9rem; background: var(--card); border: 1px solid var(--line); }
.alerts li::before { position: absolute; left: 10px; font-weight: 700; }
.alerts .ko::before { content: "✕"; color: var(--ko); } .alerts .warn::before { content: "!"; color: var(--warn); }
.alerts .info::before { content: "i"; color: var(--info); }

.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #e6ebf0; color: var(--muted); }
.pill.ok { background: #e3f5ea; color: var(--ok); } .pill.ko { background: #fde8e8; color: var(--ko); }
.pill.warn { background: #fdf3dc; color: var(--warn); } .pill.encours { background: #e6eefa; color: var(--info); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 0 0 16px; }
fieldset.panel legend { font-weight: 600; padding: 0 6px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.stack { display: grid; gap: 12px; } .narrow { max-width: 560px; }
.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline input { width: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.actions.sticky { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); padding: 12px 0; backdrop-filter: blur(4px); z-index: 2; }
.checks { display: grid; gap: 6px; } .checks.cols3 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.checks-inline { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.textarea, textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-decoration: none; color: var(--ink); display: grid; gap: 6px; }
.card:hover { border-color: var(--accent); }
.card.current { box-shadow: inset 0 3px 0 var(--accent); }
.progress { height: 6px; border-radius: 3px; background: #e6ebf0; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }

.weekbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.weekbar input[type=week] { width: auto; }
.weektitle { font-size: 1.05rem; margin: 0 6px; }

.days { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.day-edit { background: var(--card); padding: 10px 12px 12px; margin: 0; min-width: 0; }
.day-edit legend { font-weight: 700; padding: 0 6px; }
.day-edit .motif { display: none; margin-top: 6px; }
.day-edit.is-off .motif { display: block; }
.day-edit.is-off .day-fields { display: none; }
.day-fields { display: grid; gap: 6px; margin-top: 8px; }
.day-fields .veg { color: #3f8f3a; font-weight: 600; }
.slot-group { border-top: 1px dashed var(--line); padding-top: 6px; }
.slot-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.slot { margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; margin-top: 3px; font-size: .8rem; }
.chips a { text-decoration: none; margin-left: 2px; }
.flag { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--warn); color: #fff; font-size: .7rem; font-weight: 800; }
.add-slot { font-size: .8rem; }

.lbl { display: inline-block; font-size: .68rem; font-weight: 800; line-height: 1; padding: 3px 5px; border-radius: 4px; color: #fff; background: var(--c, #555); vertical-align: middle; }
.lbl-logo { height: 22px; width: auto; vertical-align: middle; }
.alg { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 999px; border: 1px solid #c9c2b5; color: var(--muted); font-size: .68rem; font-weight: 700; }

.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { background: #f6f8fa; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table .num { text-align: right; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.filters input[type=search], .filters select { width: auto; min-width: 180px; flex: 0 1 360px; }

.label-row { display: grid; grid-template-columns: 90px repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.label-row h2, .label-row .actions, .label-row .checks-inline { grid-column: 1 / -1; }
.label-row .actions { margin-top: 0; }
.label-row.is-off { opacity: .6; }
.label-row .preview { align-self: center; }

.stats { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 8px; }
.meter { position: relative; display: block; height: 8px; background: #e6ebf0; border-radius: 4px; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }

.form-plat { max-width: 900px; display: grid; gap: 12px; }
.gemrcn .check { align-items: flex-start; } .gemrcn .check input { margin-top: 3px; }
.gemrcn .check.dim { display: none; }

.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 440px; }
.auth-box h1 { color: var(--accent); margin-bottom: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .sidenav a { white-space: nowrap; }
  .content { padding: 16px; }
  .table { display: block; overflow-x: auto; }
}

/* Multi-cantines */
.topbar.is-super { background: #1f2a37; }
.navtitle { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 12px 12px 4px; }
.sidenav form { padding: 8px 12px; margin: 0; }
.promo-banner { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; background: #fdf3e6; border: 1px solid #f1dcc0; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: .9rem; }
.promo-banner p { margin: 0; } .promo-banner form { margin: 0; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.status-attente { color: var(--warn); } .status-suspendue { color: var(--ko); } .status-active { color: var(--ok); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi strong { display: block; font-size: 1.6rem; }
.danger-zone { border-color: #f2c1c1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: var(--card); font-size: .9rem; }
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.maillog { margin: 0; max-height: 260px; overflow: auto; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: .78rem; white-space: pre-wrap; word-break: break-word; }
fieldset[disabled] { opacity: .6; }
.days-table { border-collapse: collapse; margin: 4px 0 6px; }
.days-table th, .days-table td { padding: 5px 10px; text-align: center; }
.days-table tbody th { text-align: left; font-weight: 500; font-size: .9rem; }
.days-table thead th { font-size: .8rem; color: var(--muted); }

/* Aide au choix des labels */
.labels-intro { display: flex; gap: 8px; margin: 0 0 12px; padding: 10px 12px; background: #eef3f8; border-radius: 10px; font-size: .88rem; color: #3b4754; line-height: 1.45; }
.label-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 8px; }
.label-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px; transition: border-color .15s, box-shadow .15s, background .15s; }
.label-card:hover { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.label-card:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 6%, #fff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 14%, transparent); }
.label-card input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--c); flex: 0 0 auto; cursor: pointer; }
.label-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.label-visual { flex: 0 0 64px; height: 36px; display: grid; place-items: center; }
.label-visual img { max-height: 36px; max-width: 64px; object-fit: contain; }
.label-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.label-name { font-weight: 600; font-size: .92rem; line-height: 1.2; }
.egalim-tag { font-size: .66rem; font-weight: 700; letter-spacing: .02em; padding: 2px 7px; border-radius: 999px; background: #e3f5ea; color: var(--ok); white-space: nowrap; }
.egalim-tag.bio { background: #3f8f3a; color: #fff; }
.egalim-tag.off { background: #e6ebf0; color: var(--muted); }
.help-btn { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--accent) 10%, #fff); color: var(--accent); font: 800 .95rem/1 var(--font);
  display: grid; place-items: center; transition: background .15s, color .15s, transform .15s; }
.help-btn:hover, .help-btn:focus-visible { background: var(--accent); color: #fff; transform: scale(1.06); outline: none; }

/* Fenêtre d'aide (popover natif) */
.help-pop { width: min(540px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; padding: 0; border: 0; border-radius: 18px;
  color: var(--ink); background: #fff; box-shadow: 0 24px 70px rgba(20,30,27,.28); }
.help-pop::backdrop { background: rgba(25,35,32,.5); backdrop-filter: blur(2px); }
.help-pop:popover-open { animation: help-in .18s ease-out; }
@keyframes help-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.help-hero { position: relative; display: flex; gap: 16px; align-items: center; padding: 20px 22px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 16%, #fff), color-mix(in srgb, var(--c) 5%, #fff)); }
.help-logo-tile { flex: 0 0 auto; width: 104px; height: 80px; display: grid; place-items: center; background: #fff; border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08); padding: 8px; }
.help-logo-tile img { width: 100%; height: 100%; object-fit: contain; }
.help-badge { font-weight: 800; font-size: .95rem; color: #fff; background: var(--c); padding: 6px 10px; border-radius: 8px; text-align: center; }
.help-kicker { margin: 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.help-hero h2 { margin: 2px 0 6px; font-size: 1.2rem; line-height: 1.2; }
.help-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255,255,255,.8);
  font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--ink); }
.help-close:hover { background: #fff; }
.help-content { padding: 18px 22px 4px; font-size: .95rem; line-height: 1.55; }
.help-content > p { margin: 0 0 12px; }
.help-callout { margin: 4px 0 12px; padding: 12px 14px; border-radius: 12px; background: #eef8f1; border-left: 4px solid var(--ok); }
.help-callout strong { display: block; color: var(--ok); font-size: .85rem; margin-bottom: 3px; }
.help-callout p { margin: 0; font-size: .9rem; }
.help-callout.off { background: #f5f2ec; border-left-color: #b5ad9f; }
.help-callout.off strong { color: var(--muted); }
.help-foot { padding: 6px 22px 20px; text-align: right; }
@media (max-width: 560px) { .help-hero { flex-direction: column; align-items: flex-start; } }
.label-row .full { grid-column: 1 / -1; }
/* Repli pour les navigateurs sans popover natif */
@supports not selector(:popover-open) {
  .help-pop { display: none; }
  .help-pop.is-open { display: block; position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 1000; }
}

.help-sub { margin: 14px 0 4px !important; font-weight: 700; font-size: .9rem; color: var(--ink); }
.help-list { margin: 0 0 12px; padding-left: 20px; font-size: .9rem; }
.help-list li { margin: 2px 0; }
.help-list li::marker { color: var(--c); }

/* Habillage « cantine » */
.auth { background: #eef2f6 radial-gradient(circle at 1px 1px, rgba(70,96,122,.10) 1px, transparent 0) 0 0 / 22px 22px; }
.auth-box { border: 2px solid #dde3ea; border-radius: 22px; box-shadow: 0 6px 0 #dde3ea; }
.auth-art { display: block; width: 100%; height: auto; border-radius: 14px; margin-bottom: 14px; }
.topbar:not(.is-super) { background: #34495e; }

.lbl-cell { white-space: nowrap; }
.lbl-cell .lbl-logo { height: 26px; margin-right: 3px; }
