/* The page frame: a floating glass menu on the left (it can fold down to icons), the content on the right.
   Colours come from the tokens at the top of app.css; behaviour (fold, flyouts, tooltips) is in menu.js. */
.app { display:flex; align-items:flex-start; min-height:calc(100vh / var(--ui-scale)); }
.pad { flex:1 1 0; min-width:0; padding:14px 20px 36px; }
main { max-width:1560px; margin:0 auto; }
.app.bare .pad { max-width:1100px; margin:0 auto; }

/* ---- the glass panel ---- */
.side { flex:none; width:200px; padding:8px; position:sticky; top:0; height:calc(100vh / var(--ui-scale)); z-index:40; transition:width 220ms ease; }
.glass { height:100%; display:flex; flex-direction:column; gap:6px; padding:6px; border-radius:var(--radius-lg);
  background:var(--glass); -webkit-backdrop-filter:blur(26px) saturate(1.6); backdrop-filter:blur(26px) saturate(1.6);
  border:1px solid var(--glassb); box-shadow:var(--glasss); }
@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))) { .glass, .flyout { background:var(--glassfallback); } }
:where(.side) button { min-height:0; padding:0; background:transparent; border:0; font:inherit; color:inherit; cursor:pointer; }
.side button:hover { background:transparent; border-color:transparent; }
.side a { text-decoration:none; }

/* header: logo, name, fold button */
.side-head { display:flex; align-items:center; justify-content:space-between; gap:6px; padding:2px 0 0 2px; min-height:32px; }
.logo { display:flex; align-items:center; gap:10px; min-width:0; color:var(--text); text-decoration:none; font-size:20px; font-weight:800; letter-spacing:-.02em; text-transform:lowercase; }
.logo-mark { display:flex; align-items:center; justify-content:center; width:32px; height:32px; flex:none; }
.logo-mark img { display:block; width:32px; height:32px; }
.side .logo-mark, .side .logo-mark img { width:30px; height:30px; }
/* two pictures of the logo; the theme shows one (same switch as the dark tokens in app.css) */
.logo-sombre { display:none !important; }
:root[data-theme="dark"] .logo-clair { display:none !important; }
:root[data-theme="dark"] .logo-sombre { display:block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-clair { display:none !important; }
  :root:not([data-theme="light"]) .logo-sombre { display:block !important; }
}
.side-toggle { display:flex; align-items:center; justify-content:center; width:30px; height:30px; flex:none; border-radius:10px; color:var(--text2); }
.side-toggle:hover { background:var(--hoverglass); color:var(--text); }
.lbl { min-width:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; max-width:200px; transition:opacity 160ms ease, max-width 220ms ease; }

/* company switcher (several companies only) */
details.more { position:relative; }
details.more .menu { position:absolute; z-index:60; min-width:190px; padding:6px; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow-pop); }
details.more .menu a, details.more .menu .signout button { display:block; width:100%; padding:9px 12px; border-radius:8px; background:transparent; color:var(--text); font-size:13.5px; text-align:left; text-decoration:none; }
details.more .menu a:hover, details.more .menu .signout button:hover { background:var(--hoverglass); }
details.more .menu a[aria-current="page"] { background:var(--eggglass); font-weight:700; }
details.profile .menu .app-version { display:block; margin:4px 6px 0; padding:8px 6px 4px; border-top:1px solid var(--border); color:var(--muted); font-size:12px; font-variant-numeric:tabular-nums; }
details.entity summary, details.profile summary { list-style:none; cursor:pointer; }
details.entity summary::-webkit-details-marker, details.profile summary::-webkit-details-marker { display:none; }
details.entity summary { display:flex; align-items:center; gap:10px; min-height:34px; padding:4px 6px; background:var(--hoverglass); border-radius:12px; font-size:14px; font-weight:600; }
details.entity summary:hover { background:var(--eggglass); }
.einit { display:flex; align-items:center; justify-content:center; width:24px; height:24px; flex:none; border-radius:8px; background:var(--surface); box-shadow:0 0 0 1px var(--border); font-size:13px; font-weight:800; }
.ename { flex:1; }
.echev { display:flex; color:var(--text2); }
details.entity .menu { top:calc(100% + 6px); left:0; right:0; }

/* menu items */
.sn-list { flex:1 1 auto; min-height:0; display:flex; flex-direction:column; gap:1px; overflow-x:hidden; overflow-y:auto; padding:3px; margin:0 -4px; scrollbar-width:thin; }
.sn { position:relative; display:flex; align-items:center; gap:8px; width:100%; height:32px; padding:0 5px; flex:none; border-radius:12px; color:var(--text2); font-size:14.5px; font-weight:600; text-align:left;
  transition:background 150ms ease, color 150ms ease; }
.sn .ic { display:flex; align-items:center; justify-content:center; width:22px; height:22px; flex:none; border-radius:9px; transition:background 150ms ease, color 150ms ease; }
.sn .lbl { flex:1 1 auto; }
.sn:hover { background:var(--hoverglass); color:var(--text); }
.sn.on { background:var(--eggglass); color:var(--text); font-weight:700; }
.sn.on .ic { background:var(--egg); color:var(--onegg); }
.sn .badge { flex:none; min-width:26px; padding:1px 8px; border-radius:999px; background:var(--onegg); color:var(--egg); font-size:12px; font-weight:700; line-height:1.5; text-align:center; }
.sn .dot { display:none; position:absolute; top:6px; right:6px; width:9px; height:9px; border-radius:50%; background:var(--egg); box-shadow:0 0 0 2px var(--surface); }
.sn .chev { display:flex; flex:none; color:var(--text2); transition:transform 150ms ease; }
.sg.open > .sg-btn .chev { transform:rotate(90deg); }
.sg > .sub { display:none; flex-direction:column; gap:2px; margin:1px 0 4px 16px; padding-left:10px; border-left:1px solid var(--border); }
.sg.open > .sub { display:flex; }
.ss { display:flex; align-items:center; min-height:28px; padding:3px 8px; line-height:1.3; border-radius:8px; color:var(--text2); font-size:13.5px; font-weight:500; text-decoration:none; transition:background 150ms ease, color 150ms ease; }
.ss:hover { background:var(--hoverglass); color:var(--text); }
.ss.not-v1, .ss.not-v1:hover, .ss.not-v1[aria-current="page"] { color:var(--err); }
.ss.ss-red, .ss.ss-red:hover, .ss.ss-red[aria-current="page"] { color:var(--err); }
.ss[aria-current="page"] { background:var(--eggglass); color:var(--text); font-weight:700; }
.sep { display:none; width:28px; height:1px; margin:6px auto; flex:none; background:var(--border); }

/* footer: who is signed in, how the books are connected, light/dark */
.side-foot { display:flex; flex-direction:column; gap:4px; padding:5px; border-radius:14px; background:var(--hoverglass); }
details.profile summary { display:flex; align-items:center; gap:8px; min-height:32px; padding:0; border-radius:10px; }
.avatar { display:flex; align-items:center; justify-content:center; width:26px; height:26px; flex:none; border-radius:50%; background:var(--egg); color:var(--onegg); font-size:15px; font-weight:800; }
.wtxt { display:flex; flex-direction:column; flex:1 1 auto; line-height:1.3; }
.wname { overflow:hidden; text-overflow:ellipsis; font-size:14px; font-weight:700; }
.conn { display:flex; align-items:center; gap:6px; min-width:0; max-width:none; font-size:12px; color:var(--text2); }
.conn span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.conn i { width:6px; height:6px; flex:none; border-radius:50%; background:var(--field); }
.conn.up i { background:var(--reperes); } .conn.down i { background:var(--err); }
details.profile .menu { bottom:calc(100% + 12px); left:-8px; right:-8px; min-width:250px; }
details.profile .who-card { display:flex; flex-direction:column; gap:1px; padding:8px 12px 10px; margin-bottom:4px; border-bottom:1px solid var(--border); color:var(--text2); font-size:12px; white-space:normal; overflow-wrap:anywhere; }
details.profile .who-card strong { color:var(--text); font-size:14px; }
details.profile .signout { margin:4px 0 0; padding-top:4px; border-top:1px solid var(--border); }
.quick-prefs { margin:0 0 4px; padding-bottom:4px; border-bottom:1px solid var(--border); }
.quick-prefs .pick { display:flex; align-items:center; gap:4px; padding:5px 12px; color:var(--text2); font-size:12px; }
.quick-prefs .pick > span { margin-right:auto; }
.side .quick-prefs .pick button { border:1px solid var(--border); border-radius:8px; padding:4px 8px; min-width:36px; color:var(--text); font-size:12px; }
.side .quick-prefs .pick button:hover { border-color:var(--field); background:var(--hoverglass); }
.side .quick-prefs .pick button[aria-pressed="true"] { background:var(--egg); border-color:var(--egg); color:var(--onegg); font-weight:700; }
.themeform { margin:0; }
.side .bt { display:flex; align-items:center; justify-content:center; gap:8px; width:100%; height:28px; border:1px solid var(--border); border-radius:10px; font-size:13px; font-weight:600; color:var(--text); }
.side .bt:hover { background:var(--hoverglass); }
.side a.bt { text-decoration:none; }
.bt .ti-tabs { display:flex; flex:none; }
.side a.help-btn { display:flex; align-items:center; justify-content:center; gap:8px; width:100%; height:28px; padding:0 10px; border-radius:10px; background:var(--egg); color:var(--onegg); font-size:13.5px; font-weight:700; text-decoration:none; white-space:nowrap; transition:filter .15s; }
.side a.help-btn:hover { filter:brightness(1.06); }
.side a.help-btn:focus-visible { outline:2px solid var(--link); outline-offset:2px; }
.side .bt-row { display:flex; gap:8px; }
.side .bt-row .bt { width:auto; flex:1; min-width:0; padding:0 6px; font-size:12.5px; line-height:1.15; text-align:center; }
.side .bt-row .bt .lbl { white-space:normal; overflow:visible; max-width:none; }
.side .bt-row .ti-tabs { display:none; }
.side .bt-row .bt-win { flex:none; width:28px; padding:0; }
.bt .ti-moon, .bt .ti-sun { display:flex; flex:none; }
.bt .ti-sun, .bt .t-light { display:none; }
:root[data-theme="dark"] .bt .ti-moon, :root[data-theme="dark"] .bt .t-dark { display:none; }
:root[data-theme="dark"] .bt .ti-sun { display:flex; } :root[data-theme="dark"] .bt .t-light { display:block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bt .ti-moon, :root:not([data-theme="light"]) .bt .t-dark { display:none; }
  :root:not([data-theme="light"]) .bt .ti-sun { display:flex; } :root:not([data-theme="light"]) .bt .t-light { display:block; }
}

/* tooltips and the small panel a folded group opens (outside the glass so nothing clips them) */
.stip { position:fixed; z-index:90; max-width:280px; padding:7px 11px; border-radius:8px; background:var(--hero); color:var(--onhero); font-size:13px; font-weight:600; line-height:1.3; box-shadow:var(--shadow-pop); pointer-events:none; }
.stip[hidden], .flyout[hidden] { display:none; }
.flyout { position:fixed; z-index:80; min-width:230px; max-width:300px; padding:8px; border-radius:20px;
  background:var(--glassfallback); -webkit-backdrop-filter:blur(26px) saturate(1.6); backdrop-filter:blur(26px) saturate(1.6); border:1px solid var(--glassb); box-shadow:var(--glasss); }
.flyout-title { padding:6px 10px 6px; font-size:11px; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:var(--text2); }
.flyout .ss { min-height:40px; font-size:14px; }

/* ---- the strip above every page: search on the left, demo notice on the right, on its own white band with a thin line ---- */
.contentbar { display:flex; flex-wrap:nowrap; align-items:center; justify-content:space-between; gap:12px; margin:0 0 16px; padding:14px 20px; background:var(--surface);
  border:1px solid var(--border); border-radius:12px; box-shadow:0 1px 2px rgba(0,0,0,.04); }
.gsearch { flex:0 1 450px; max-width:450px; margin:0; }
.gsearch label { position:relative; display:block; }
.gsearch .ni { position:absolute; left:12px; top:50%; transform:translateY(-50%); width:16px; height:16px; color:var(--text2); pointer-events:none; }
.contentbar .gsearch input { height:34px; padding:0 12px 0 36px; border-radius:9px; background:var(--surface2); border:1px solid var(--border); font-size:13px;
  box-shadow:0 1px 2px rgba(0,0,0,.05); transition:background .15s ease, border-color .15s ease; }
.contentbar .gsearch input:focus { background:var(--surface); border-color:var(--egg); outline:none; box-shadow:0 0 0 2px color-mix(in srgb, var(--egg) 45%, transparent); }
.contentbar.big .gsearch input { height:48px; }
.contentbar .gsearch input::placeholder { color:var(--text2); opacity:1; }
@media (prefers-reduced-motion: reduce) { .contentbar .gsearch input { transition:none; } }
@media (max-width: 640px) { .contentbar { flex-wrap:wrap; padding:12px 14px; } .gsearch { flex:1 1 100%; max-width:none; } }
.demo-pill { display:inline-flex; flex:none; align-items:center; gap:8px; margin-left:auto; padding:6px 12px; border:1px solid var(--accent-border); border-radius:999px; background:var(--eggsoft); color:var(--text); font-size:12px; }
.demo-pill .ni { color:var(--link); flex:none; }
.notice { display:flex; flex-wrap:wrap; align-items:center; gap:6px 14px; margin-bottom:16px; padding:10px 16px; border-radius:12px; background:var(--warnbg); color:var(--text); font-size:13px; }
.notice.err { background:var(--errbg); }
.notice > span { flex:1 1 240px; min-width:0; }
.notice a { font-weight:700; }
.notice button { margin-left:auto; }
.app.bare .contentbar { justify-content:flex-start; background:none; border:0; box-shadow:none; padding:0; }
.app.bare .demo-pill { margin-left:0; }

/* ---- folded menu (wide screens only; on a phone the menu is a drawer) ---- */
@media (min-width: 821px) {
  html[data-menu="collapsed"] .side { width:104px; }
  html[data-menu="collapsed"] .lbl, html[data-menu="collapsed"] .sn .badge, html[data-menu="collapsed"] .sn .chev, html[data-menu="collapsed"] .echev { opacity:0; max-width:0; flex:0 0 0; margin:0; display:none; }
  html[data-menu="collapsed"] .glass { align-items:center; }
  html[data-menu="collapsed"] .side-head { flex-direction:column; gap:10px; padding:2px 0 0; }
  html[data-menu="collapsed"] .sn-list, html[data-menu="collapsed"] .sg { align-items:center; width:100%; }
  html[data-menu="collapsed"] .sg { display:flex; flex-direction:column; }
  html[data-menu="collapsed"] .sn-list { margin:0; scrollbar-width:none; }
  html[data-menu="collapsed"] .sn-list::-webkit-scrollbar { display:none; }
  html[data-menu="collapsed"] .sn { width:44px; height:44px; gap:0; padding:0; justify-content:center; border-radius:12px; }
  html[data-menu="collapsed"] .sn .ic, html[data-menu="collapsed"] .sn.on .ic { width:20px; height:20px; background:transparent; color:inherit; }
  html[data-menu="collapsed"] .sn.on .ic { color:var(--link); }
  html[data-menu="collapsed"] .sn .dot { display:block; }
  html[data-menu="collapsed"] .sg > .sub, html[data-menu="collapsed"] .sg.open > .sub { display:none; }
  html[data-menu="collapsed"] .sep { display:block; margin:3px auto; }
  html[data-menu="collapsed"] .glass { gap:10px; }
  html[data-menu="collapsed"] details.entity summary { justify-content:center; width:44px; min-height:44px; padding:0; background:transparent; }
  html[data-menu="collapsed"] details.entity summary:hover { background:var(--eggglass); }
  html[data-menu="collapsed"] details.entity .menu { top:0; left:calc(100% + 26px); right:auto; }
  html[data-menu="collapsed"] .side-foot { flex-direction:column-reverse; align-items:center; gap:6px; padding:0; background:transparent; }
  html[data-menu="collapsed"] details.profile summary { justify-content:center; width:44px; }
  html[data-menu="collapsed"] details.profile .menu { bottom:0; left:calc(100% + 26px); right:auto; }
  html[data-menu="collapsed"] .side a.help-btn { width:40px; padding:0; border-radius:50%; gap:0; }
  html[data-menu="collapsed"] .side .bt { width:40px; border-radius:50%; gap:0; }
  html[data-menu="collapsed"] .side .bt-row { flex-direction:column; align-items:center; gap:6px; }
  html[data-menu="collapsed"] .side .bt-row .bt { flex:none; padding:0; }
  html[data-menu="collapsed"] .side .bt-row .ti-tabs { display:flex; }
}

/* ---- phone and small tablet: a slim top bar, the menu is a drawer that slides in from the left ---- */
.mbar, .scrim, .side-close { display:none; }
@media (max-width: 820px) {
  .app { flex-direction:column; align-items:stretch; }
  .mbar { position:sticky; top:0; z-index:30; display:flex; align-items:center; justify-content:space-between; gap:8px; height:56px; padding:0 8px 0 16px;
    background:var(--bg); border-bottom:1px solid var(--border); }
  .mbar .logo { font-size:18px; }
  .mbar .logo-mark, .mbar .logo-mark img { width:36px; height:36px; }
  .mbar-btn { display:flex; align-items:center; justify-content:center; width:44px; height:44px; flex:none; padding:0; border-radius:12px; background:transparent; border:0; color:var(--text); cursor:pointer; }
  .mbar-btn:hover { background:var(--hoverglass); }
  .scrim { display:block; position:fixed; inset:0; z-index:45; background:color-mix(in srgb, var(--hero) 50%, transparent); opacity:0; transition:opacity 200ms ease; }
  .scrim[hidden] { display:none; }
  .scrim.show { opacity:1; }
  .side { position:fixed; top:0; left:0; bottom:0; z-index:50; width:min(86vw, 320px); height:100vh; height:100dvh; padding:0;
    transform:translateX(-102%); visibility:hidden; transition:transform 200ms ease, visibility 0s linear 200ms; }
  .side.open { transform:none; visibility:visible; transition:transform 200ms ease, visibility 0s; }
  .glass { background:var(--glassfallback); border-radius:0 var(--radius-lg) var(--radius-lg) 0;padding-top:max(12px, env(safe-area-inset-top)); padding-bottom:max(12px, env(safe-area-inset-bottom)); }
  .side-toggle { display:none; }
  .side-close { display:flex; align-items:center; justify-content:center; width:44px; height:44px; flex:none; border-radius:12px; color:var(--text2); }
  .side-close:hover { background:var(--hoverglass); color:var(--text); }
  .sn.nav-photo { order:-1; }
  details.profile .menu { left:0; right:0; }
  .pad { padding:20px 24px 56px; }
  /* phones keep the roomier sizes (the page is drawn at full size there) */
  .glass { gap:14px; padding-left:12px; padding-right:12px; }
  .side-head { min-height:44px; }
  .side .logo-mark, .side .logo-mark img { width:44px; height:44px; }
  details.entity summary { min-height:52px; padding:8px 10px; }
  .sn { height:44px; gap:10px; padding:0 8px; border-radius:14px; }
  .sn .ic { width:30px; height:30px; border-radius:10px; }
  .sg > .sub { margin:2px 0 6px 19px; padding-left:12px; }
  .ss { min-height:34px; padding:6px 10px; }
  .side-foot { gap:8px; padding:8px; }
  details.profile summary { gap:10px; min-height:44px; }
  .avatar { width:36px; height:36px; }
  .side .bt, .side a.help-btn { height:40px; }
  .side .bt-row .bt-win { width:40px; }
  .stip, .flyout { display:none !important; }
  html.menu-lock, html.menu-lock body { overflow:hidden; }
}
@media (max-width: 640px) { .pad { padding:20px 16px 48px; } }
@media (prefers-reduced-motion: reduce) { .side, .scrim, .lbl, .sn, .sn .ic, .sn .chev, .ss { transition:none !important; } }
@media print { .side, .mbar, .scrim { display:none; } .pad { padding:0; } }

/* while the menu is put back as it was (base.html), nothing slides */
html.menu-restoring .side, html.menu-restoring .side * { transition:none !important; }
