/* Cabanon: tokens, page frame, controls, panels, tables, windows — what every screen uses. */
:root {
  --bg: #f2f2f0; --surface: #fff; --surface-2: #ebebe8; --text: #1a1a1a; --muted: #666;
  --line: #cfcfca; --line-strong: #1a1a1a;
  --accent: #007b46; --accent-ink: #fff; --accent-soft: #e3f1ea;
  --danger: #b71c1c; --warn: #d84315; --soon: #e0a100; --ok: #007b46;
  --shadow: 0 0 0 1px var(--line-strong);
  /* The frames come in two weights. --frame (black) is kept for what one acts on — buttons, fields, the
     header, a window — and --frame-soft (grey) for what only groups things, so that a page of six panels
     no longer reads as six equal boxes. */
  --frame: var(--line-strong); --frame-soft: #a9a9a4;
  /* type: one family for the interface, one monospace for codes and the name of the application */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: .75rem; --fs-sm: .85rem; --fs-md: 1rem; --fs-h1: 1.5rem;
  /* spacing steps, used by the controls and the panels */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .8rem; --sp-4: 1rem; --sp-5: 1.5rem;
  --tabbar-h: 0px;
  font-family: var(--font-ui);
  font-size: 15px; line-height: 1.4; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121212; --surface: #1a1a1a; --surface-2: #242424; --text: #e8e8e6; --muted: #9a9a96;
  --line: #363636; --line-strong: #e8e8e6;
  --accent: #34b87a; --accent-ink: #06160d; --accent-soft: #12281d;
  --danger: #ef5350; --warn: #ff8a3d; --soon: #f2c230; --ok: #34b87a;
  --frame-soft: #4a4a48;
  color-scheme: dark;
}
* { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; overflow-x: hidden; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
#app > main { flex: 1 0 auto; width: 100%; }
.foot { text-align: center; padding: 1rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); margin-top: 1.5rem; }
#app > .foot { width: 100%; margin-top: 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: var(--fs-h1); letter-spacing: -.01em; }
/* h2 titles a panel: a small caption in capitals rather than a second headline competing with the h1 */
h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
h3 { font-size: var(--fs-md); }
a { color: var(--accent); }
code, .mono { font-family: var(--font-mono); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; }
.spacer { height: 1rem; }

/* ---------- header ---------- */
header.top { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 2px solid var(--line-strong); }
.top-in { display: flex; align-items: center; gap: 1rem; padding: .4rem 1rem; max-width: 1600px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand img { height: 34px; width: auto; display: block; }
/* Wordmark: used only where "Cabanon" sits right next to the logo (header, login screen). */
.cab-wordmark { font-family: var(--font-mono); letter-spacing: .01em; }
nav.main { display: flex; gap: 0; }
nav.main a { padding: .55rem .8rem; text-decoration: none; color: var(--text); border-bottom: 3px solid transparent; white-space: nowrap; }
nav.main a:hover { background: var(--surface-2); }
nav.main a.on { border-bottom-color: var(--accent); font-weight: 600; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; margin-left: auto; }
.search input { width: 100%; font-family: var(--font-mono); }
.search-res { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-top: 0; max-height: 60vh; overflow: auto; z-index: 30; }
.search-res button { display: flex; width: 100%; gap: .6rem; justify-content: flex-start; border: 0; border-bottom: 1px solid var(--line); background: none; padding: .45rem .6rem; text-align: left; }
.search-res button:hover, .search-res button.sel { background: var(--accent-soft); }
.top-tools { display: flex; gap: .4rem; align-items: center; }
.top-tools button { white-space: nowrap; }
/* A menu keeps its own width in a crowded row: squeezed, "Plus ▾" wrapped onto two lines and the button
   came out square. */
.menu { position: relative; flex: 0 0 auto; }
.menu > button { white-space: nowrap; }
.menu-pop { position: absolute; right: 0; top: 100%; min-width: 210px; background: var(--surface); border: 1px solid var(--line-strong); z-index: 30; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: .55rem .8rem; border: 0; background: none; color: var(--text); text-decoration: none; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--accent-soft); }
.menu-pop .who { padding: .5rem .8rem; border-bottom: 1px solid var(--line); }

main { max-width: 1600px; margin: 0 auto; padding: 1rem; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem; }
.page-head h1 { margin-right: auto; }

/* ---------- buttons & fields ---------- */
button, .btn { font: inherit; cursor: pointer; padding: .42rem .85rem; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; line-height: 1.2; }
button:hover, .btn:hover { background: var(--surface-2); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.1); background: var(--accent); }
button.danger, .btn.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger); color: #fff; }
button.ghost { border-color: transparent; background: none; } button.ghost:hover { background: var(--surface-2); }
button.small, .btn.small { padding: .22rem .55rem; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select { max-width: 100%; text-overflow: ellipsis; }
.field, .grid2 > *, .grid3 > * { min-width: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); padding: .4rem .55rem; min-width: 0; }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; padding: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
label { display: block; }
.field { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .7rem; }
.field > span.lbl { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.field .hint { font-size: .8rem; color: var(--muted); }
.inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; } .inline > * { flex: 0 1 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 .8rem; }
.radios { display: flex; gap: 1rem; flex-wrap: wrap; } .radios label { display: flex; gap: .35rem; align-items: center; cursor: pointer; }
/* stacked choices, used by the CSV import window where each option needs a line of its own */
.radios.col { flex-direction: column; gap: .4rem; }
.radios.col label { align-items: flex-start; }
.radios.col input { margin-top: .2rem; flex: none; }
.bullets { margin: .2rem 0 .4rem 1.1rem; padding: 0; }
.bullets li { margin: .15rem 0; }
.import-summary { border-top: 1px solid var(--line); margin-top: .8rem; padding-top: .7rem; }
.import-report { color: var(--text); font-size: .92rem; }
.import-report details { margin-top: .4rem; }
.import-report summary { cursor: pointer; color: var(--accent); }
.err { color: var(--danger); margin: .3rem 0 .6rem; font-weight: 600; } .err:empty { display: none; }

/* ---------- cards / panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--frame-soft); }
.panel > .ph { display: flex; align-items: center; gap: .6rem; padding: .55rem var(--sp-3); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.panel > .ph h2 { margin-right: auto; }
.panel > .pb { padding: .8rem; } .panel > .pb.flush { padding: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
.actions4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.actions4 button { flex-direction: column; justify-content: center; padding: 1.1rem .5rem; font-size: 1rem; font-weight: 600; border-width: 2px; gap: .35rem; }
.actions4 button .ic { font-size: 1.5rem; line-height: 1; font-family: var(--font-mono); }
.actions4 button.add { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.actions4 button.add:hover { filter: brightness(1.1); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0; border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.stat { padding: .7rem .8rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat.bad b { color: var(--danger); } .stat.warn b { color: var(--warn); } .stat.soon b { color: var(--soon); }

/* ---------- tables ---------- */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .42rem .6rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line-strong); white-space: nowrap; user-select: none; position: sticky; top: 0; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
th .arr { color: var(--accent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.chk, th.chk { width: 2rem; padding-right: 0; }
tbody tr:hover { background: var(--accent-soft); }
tr.clickable { cursor: pointer; }
tr.sel { background: var(--accent-soft); outline: 1px solid var(--accent); outline-offset: -1px; }
tr.grp td { background: var(--surface-2); font-weight: 700; border-bottom: 1px solid var(--line-strong); text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; }
tr.grp:hover { background: var(--surface-2); }
tr.st-perime td:first-child, tr.st-alerte td:first-child, tr.st-avenir td:first-child { box-shadow: inset 4px 0 0 var(--c); }
tr.st-perime { --c: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
tr.st-alerte { --c: var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent); }
tr.st-avenir { --c: var(--soon); background: color-mix(in srgb, var(--soon) 10%, transparent); }
.code { font-family: var(--font-mono); font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.badge { display: inline-block; padding: .05rem .4rem; font-size: .75rem; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.badge.perime { color: var(--danger); } .badge.alerte { color: var(--warn); } .badge.avenir { color: var(--soon); } .badge.ok { color: var(--ok); } .badge.gris { color: var(--muted); }
.empty { padding: 1.4rem; text-align: center; color: var(--muted); }
.bulk { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .5rem .8rem; background: var(--accent); color: var(--accent-ink); position: sticky; top: 58px; z-index: 5; }
.bulk button { background: var(--surface); }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .7rem; }
.filters { padding: .7rem .8rem; border: 1px solid var(--line-strong); background: var(--surface); margin-bottom: .7rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.filters h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .3rem; }
.filters label { display: flex; gap: .4rem; align-items: center; padding: .1rem 0; }

/* ---------- windows ---------- */
/* Above the map: Leaflet raises its own panes and controls up to z-index 1000, and a window opened over a
   map was painted underneath it — the form was there, unreachable, with the map on top. */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 1200; overflow: auto; }
.modal { background: var(--surface); border: 2px solid var(--line-strong); width: min(560px, 100%); }
.modal.wide { width: min(780px, 100%); }
.modal.xwide { width: min(1080px, 100%); }
.modal .tw input[type=text] { width: 100%; min-width: 9rem; }
.modal > .mh { display: flex; align-items: center; padding: .6rem .9rem; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); gap: .5rem; }
.modal > .mh h2 { margin-right: auto; text-transform: none; letter-spacing: 0; font-size: 1.1rem; }
.modal > .mb { padding: .9rem; }
.modal > .mf { padding: .7rem .9rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .6rem 0; }
.kv dt { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; } .kv dd { margin: 0; }
.bigcode { font-size: 1.9rem; }
.pick { border: 1px solid var(--line); max-height: 280px; overflow: auto; }
.pick label { display: flex; gap: .6rem; align-items: center; padding: .4rem .6rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick label:hover { background: var(--accent-soft); }
.pick input[type=number] { width: 4.5rem; }

#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 1300; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-left: 5px solid var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.toast.error { border-left-color: var(--danger); }

/* ---------- sign-in ---------- */
.login { flex: 1 0 auto; width: 100%; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login .panel { width: min(380px, 100%); }
.msort { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.idbox { display: block; font-family: var(--font-mono); word-break: break-all; padding: .6rem .7rem; background: var(--surface-2); border: 1px solid var(--line-strong); user-select: all; }
.sub { margin-top: 1rem; } .sub h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .3rem; }
.prow { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .4rem 0; border-bottom: 1px solid var(--line); }
button.linklike { color: var(--accent); font-weight: 600; padding-left: 0; }
.login img { height: 110px; display: block; margin: 0 auto .6rem; }
.login h1 { text-align: center; margin-bottom: 1rem; }

/* ---------- "i" help, introductions, objectives ---------- */
button.info { min-height: 0 !important; width: 1.15rem; height: 1.15rem; padding: 0; justify-content: center; font: italic 700 .75rem/1 Georgia, serif; text-transform: none; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); vertical-align: middle; }
button.info:hover, button.info[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); }
.infotext { font-size: .82rem; line-height: 1.35; padding: .45rem .6rem; background: var(--accent-soft); border-left: 3px solid var(--accent); color: var(--text); }
.field > span.lbl button.info { margin-left: .25rem; }
.intro { margin: -.3rem 0 1rem; color: var(--muted); max-width: 70ch; }
.nowrapx { flex-wrap: nowrap; } .nowrapx select { flex: 1 1 auto; min-width: 0; }
.goals { padding: .8rem; border-top: 1px solid var(--line); }
.goals h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .5rem; }
/* the dashboard points at the goals page instead of listing the goals itself */
.goals-link { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .8rem; border-top: 1px solid var(--line); }
/* one line of the bulk-edit window: the switch, the control, and what the selection holds today */
.bulk-row { display: grid; grid-template-columns: 14rem auto 1fr; gap: .6rem; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.bulk-row:last-child { border-bottom: 0; }
@media (max-width: 700px) { .bulk-row { grid-template-columns: 1fr; gap: .2rem; } }

/* figures of a basket or of a container, above its contents */
.recap { margin-bottom: 1rem; }
.recap-note { padding: .5rem .8rem; margin: 0; border-top: 1px solid var(--line); }
.goal { margin-bottom: .7rem; }
.goal-h { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .2rem; }
.bar { height: 12px; background: var(--surface-2); border: 1px solid var(--line-strong); }
.bar > i { display: block; height: 100%; background: var(--c, var(--accent)); }
.bar.ok { --c: var(--ok); } .bar.mid { --c: var(--soon); } .bar.low { --c: var(--warn); }

/* ---------- notices, terms of use ---------- */
.notice { border: 1px solid var(--warn); border-left-width: 5px; background: color-mix(in srgb, var(--warn) 10%, var(--surface)); padding: .6rem .8rem; margin-bottom: 1rem; max-width: 70ch; }
.notice p { margin: .2rem 0; }
.legal-page { flex: 1 0 auto; width: 100%; max-width: 860px; margin: 0 auto; padding: 1rem; }
.legal h2 { text-transform: none; letter-spacing: 0; font-size: 1.1rem; margin: 1.4rem 0 .4rem; }
.legal p, .legal li { line-height: 1.5; }
.legal ul { padding-left: 1.2rem; }
mark.todo { background: #fff3a0; color: #000; padding: 0 .25rem; font-weight: 600; }
.cgu { align-items: flex-start; margin: .6rem 0; flex-wrap: nowrap; }
.cgu input { margin-top: .2rem; flex: none; }
.cgu span { flex: 1 1 0; min-width: 0; }

@media (max-width: 1240px) {
  .top-in { flex-wrap: wrap; gap: .4rem .8rem; }
  nav.main { order: 5; width: calc(100% + 2rem); overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; border-top: 1px solid var(--line); }
  .brand { order: 1; } .search { order: 2; max-width: none; flex: 1 1 200px; margin-left: 0; } .top-tools { order: 3; margin-left: auto; }
}
@media (max-width: 900px) {
  .search { order: 4; flex-basis: 100%; }
  .brand span { display: none; }
  .actions4 { grid-template-columns: 1fr 1fr; }
  .cols { grid-template-columns: 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .bulk { top: 0; }
}

@media (max-width: 700px) {
  html { font-size: 16px; }
  main { padding: .7rem; }
  .top-in { padding: .4rem .7rem; }
  /* the tools move to the bar at the bottom of the screen (nav.tabbar, below) */
  header.top nav.main { display: none; }
  button, .btn, input, select, textarea { min-height: 42px; }
  button.small, .btn.small { min-height: 34px; }
  .page-head h1 { flex: 1 1 100%; }
  .toolbar > input, .toolbar > select { flex: 1 1 100%; }
  .actions4 button { padding: .8rem .4rem; }
  .overlay { padding: 0; }
  .modal, .modal.wide { width: 100%; min-height: 100vh; border-width: 0; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: .5rem; }
  .bulk { position: static; }
  .msort { display: flex; gap: .4rem; padding: .5rem .6rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
  .msort select { flex: 1 1 auto; }
  .tw table, .tw tbody { display: block; }
  .tw thead { display: none; }
  .tw tr { display: block; position: relative; padding: .55rem .7rem .55rem .7rem; border-bottom: 1px solid var(--line-strong); }
  .tw tr.grp { padding: .4rem .7rem; }
  .tw td { display: flex; justify-content: space-between; gap: .8rem; border: 0; padding: .12rem 0; text-align: right; }
  .tw td::before { content: attr(data-label); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; text-align: left; flex: 0 0 auto; padding-top: .15rem; }
  .tw td.nv { display: none; }
  .tw td.c-code { padding-right: 2.2rem; }
  .tw td.c-nom { font-weight: 700; font-size: 1.05rem; text-align: left; padding-right: 2.2rem; }
  .tw td.c-nom::before { display: none; }
  .tw td.chk { position: absolute; top: .5rem; right: .6rem; width: auto; padding: 0; display: block; }
  .tw td.chk::before, .tw td[data-label=""]::before { display: none; }
  .tw td.right { justify-content: flex-end; }
  .tw td.right::before { display: none; }
  .tw tr.st-perime td:first-child, .tw tr.st-alerte td:first-child, .tw tr.st-avenir td:first-child { box-shadow: none; }
  .tw tr.st-perime, .tw tr.st-alerte, .tw tr.st-avenir { box-shadow: inset 5px 0 0 var(--c); }
  .tw tr.grp td { display: block; text-align: left; } .tw tr.grp td::before { display: none; }
  .tw td:not([data-label])::before { display: none; }
  /* places, rooms, containers: name and code on the first line, then the other values two by two, actions at the bottom left */
  table.places tr { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .9rem; align-items: start; }
  table.places td { display: block; text-align: left; padding: 0; min-width: 0; overflow-wrap: anywhere; }
  table.places td::before { display: block; padding: 0; }
  table.places td.c-nom { grid-column: 1; grid-row: 1; font-weight: 700; font-size: 1.05rem; padding-right: 0; }
  table.places td.c-code { grid-column: 2; grid-row: 1; text-align: right; padding-right: 0; }
  table.places td.c-nom::before, table.places td.c-code::before, table.places td.c-actions::before { display: none; }
  table.places td.c-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-start; padding-top: .4rem; }
  table.places td.num { text-align: left; }
}

/* ================= the daily-life tools (1.10) ================= */

/* ---------- the second row of the menu, for the pages of the stock ---------- */
/* The band spans the window, but its first link lines up with the page below it: the header and the main
   area are a centred column of 1600px, and the row of stock pages used to hug the left edge of the screen. */
nav.sub { display: flex; gap: 0; margin-top: 0; overflow-x: auto; background: var(--surface-2); border-top: 1px solid var(--line);
  /* the .8rem is the padding of the links themselves, taken off so that the first label — not its box —
     starts exactly under the page title */
  padding: 0 calc(max(0px, (100% - 1600px) / 2) + .2rem); }
nav.sub a { padding: .4rem .8rem; font-size: .9rem; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
nav.sub a:hover { color: var(--text); }
nav.sub a.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
nav.sub { background: var(--surface); }

/* ---------- the icons of the interface (js/icons.js) ---------- */
svg.ico { display: inline-block; vertical-align: -.18em; flex: none; }
.bell svg.ico { vertical-align: middle; }

/* ---------- the bar at the bottom of a phone ---------- */
nav.tabbar { display: none; }
@media (max-width: 700px) {
  /* only where the bar is drawn: the Messagerie app has none */
  :root:has(nav.tabbar) { --tabbar-h: 3.6rem; }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
  nav.tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: var(--surface); border-top: 2px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom, 0px); }
  nav.tabbar > a, nav.tabbar .tb-plus { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    min-height: var(--tabbar-h); padding: .3rem .1rem; border: 0; border-top: 3px solid transparent; background: none;
    color: var(--muted); text-decoration: none; font-size: .72rem; width: 100%; }
  nav.tabbar > a.on, nav.tabbar .tb-plus.on { color: var(--text); font-weight: 700; border-top-color: var(--accent); }
  nav.tabbar svg.ico { width: 1.45rem; height: 1.45rem; }
  .tb-more { position: relative; display: flex; }
  .tb-plus .badge { position: absolute; top: .3rem; right: 22%; margin: 0 !important; font-size: .65rem; background: var(--danger); color: #fff; border-color: var(--danger); }
  .tb-sheet { position: absolute; right: 0; bottom: 100%; min-width: 15rem; background: var(--surface); border: 1px solid var(--line-strong);
    border-bottom: 0; box-shadow: 0 -4px 14px rgba(0,0,0,.15); }
  .tb-sheet a { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
  .tb-sheet a:hover, .tb-sheet a.on { background: var(--accent-soft); }
  .tb-sheet hr { border: 0; border-top: 1px solid var(--line-strong); margin: 0; }
  .tb-sheet a:not(:has(svg)) { padding-left: 3.15rem; }
  /* what stays fixed at the bottom of the window rises above the bar */
  #toasts { bottom: calc(var(--tabbar-h) + 1rem); }
}

/* ---------- a plain surface, used by every new screen ---------- */
.card { background: var(--surface); border: 1px solid var(--frame-soft); padding: var(--sp-3); margin-bottom: var(--sp-4); }
.card > h2 { margin-bottom: .5rem; }
.card.sub { border-color: var(--line); margin: .5rem 0; }
.card.accent { border-left: 5px solid var(--accent); background: var(--accent-soft); }
.row.wrap { flex-wrap: wrap; } .row.end { align-items: flex-end; }
/* The field keeps a margin under it, which would leave the button of the row lower than the box
   it goes with: on a row aligned at the bottom, that margin goes. */
.row.end > .field { margin-bottom: 0; }
.clickable { cursor: pointer; }
.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border: 1px solid var(--line-strong); }
.big-emoji { font-size: 3rem; line-height: 1; }

/* one row of a list: a line of items that wraps on a small screen */
.line { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line.done > label, .line.done b { color: var(--muted); text-decoration: line-through; }
.line.clickable:hover { background: var(--accent-soft); }
button.link-x { border: 0; background: none; color: var(--muted); padding: 0 .3rem; min-height: 0; font-size: .95rem; }
button.link-x:hover { color: var(--danger); }
button.link-x[disabled] { opacity: .3; }
label.chip-check { border: 1px solid var(--line); padding: .15rem .5rem; gap: .35rem; }

/* ---------- tabs (shopping lists, task lists) ---------- */
.tabs { gap: .25rem; margin-bottom: .8rem; overflow-x: auto; }
button.tab { border-color: var(--line); background: var(--surface); color: var(--muted); display: inline-flex; gap: .4rem; }
button.tab.on { border-color: var(--line-strong); color: var(--text); font-weight: 700; background: var(--surface-2); }


/* a goal badge next to a quantity needs air, or the two read as one word */
.badge.objectif { margin-left: .45rem; }

/* ---- the bell: what happened while one was elsewhere ---- */
.bell-wrap { position: relative; }
.bell { position: relative; padding: .3rem .5rem; font-size: 1.05rem; line-height: 1; }
.bell-n { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; padding: 0 .3rem; line-height: 1.3; }
.notif-pop { position: absolute; right: 0; top: calc(100% + .3rem); z-index: 80; width: min(420px, 92vw);
  max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22); }
.notif-tete { display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem;
  border-bottom: 1px solid var(--line-strong); background: var(--surface-2); position: sticky; top: 0; }
.notif { display: block; padding: .5rem .8rem; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--accent-soft); }
.notif.non-lu { box-shadow: inset 4px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.notif-quand { display: block; font-size: .78rem; color: var(--muted); }
.notif-vide { padding: 1rem .8rem; margin: 0; }

/* ---------- Mon compte: a list of sections on the left, the panels two by two ---------- */
.compte { min-width: 0; display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.compte-nav { position: sticky; top: calc(var(--header-sticky, 60px) + 1rem); display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--line); }
.compte-nav button { border: 0; background: none; text-align: left; justify-content: flex-start; padding: .45rem .8rem; margin-left: -2px; border-left: 2px solid transparent; color: var(--text); }
.compte-nav button:hover { border-left-color: var(--accent); background: var(--surface-2); }
.compte-nav a { padding: .8rem .8rem 0; }
.compte-groupe { scroll-margin-top: 5rem; }
.compte-groupe + .compte-groupe { margin-top: 1.6rem; }
.compte-titre { font-size: 1.1rem; margin-bottom: .6rem; padding-bottom: .3rem; border-bottom: 2px solid var(--line-strong); }
.compte-panneaux { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); gap: 1rem; align-items: start; }
@media (max-width: 900px) {
  .compte { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .compte-nav { position: static; flex-direction: row; flex-wrap: wrap; border-left: 0; border-bottom: 1px solid var(--line); }
  .compte-nav button { margin: 0; border-left: 0; border-bottom: 2px solid transparent; }
  .compte-nav a { display: none; }
}
