/* The bar at the top and the menu of a phone, as in the Service Desk (the owner, 28. 11. 2026). One shared piece for CRM, Finance and Smart:
   the same classes (.menu-toggle, .drawer-head, .drawer-close, .drawer-scrim, .side-menu, .top-acts) and the script public/js/menu.js.
   Up to 860 px: on the left the "sandwich" (bars-staggered) and the logo, on the right the bell, the light/dark mode and the globe (44 px).
   The sandwich slides the menu in from the left over the page (a dark veil behind it): the logo and a cross on top, the circles of the
   companies, the items one under another, the user and O aplikaci at the bottom. A click beside it, the cross or Escape closes it.
   A computer (861 px and more) is not touched: these pieces are not there or have no box of their own. */

.menu-toggle,
.drawer-head,
.drawer-scrim {
  display: none;
}
.side-menu,
.top-acts,
.head-row {
  display: contents;
}

@media (max-width: 860px) {
  .shell {
    position: relative;
  }
  /* the bar: the room on the right belongs to the three buttons (.top-acts), which stand over it */
  html .shell > .side,
  html.sd .shell > .side {
    position: static;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: auto;
    min-height: 64px;
    overflow: visible;
    padding: 10px 172px 10px 10px;
  }
  /* the closed bar shows only the sandwich (the owner, 28. 11. 2026): the logo is inside the open card, not beside the sandwich */
  .side-head {
    display: none;
  }
  .side-head .logo-pill,
  .drawer-head .logo-pill {
    padding: 0;
  }
  .side .logo-pill img.logo {
    width: 84px;
    max-width: 84px;
    height: auto;
  }
  .side-head .side-hide {
    display: none;
  }

  /* the sandwich: the same three lines as the sandwich of the menu on a computer (one drawing, layout.ts burgerIcon) */
  .menu-toggle,
  .drawer-close {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
  }
  .menu-toggle:hover,
  .drawer-close:hover {
    background: color-mix(in srgb, var(--ink) 8%, transparent);
  }
  .menu-toggle:focus-visible,
  .drawer-close:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }

  /* the bell, the mode and the globe: in the bar on the right */
  .top-acts {
    display: flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: 10px;
    right: 16px;
    z-index: 30;
  }
  html.sd .top-acts .bell-btn,
  html.sd .top-acts .theme-toggle,
  html.sd .top-acts .dd > button {
    width: 44px;
    height: 44px;
  }

  /* the row under the bar: the way (crumbs) on the left and the search on the right in the free room; when the way is long, the search goes
     under it over the whole width (the way is never cut). On Domů (no way) the quick buttons stand there instead of the way. The tabs of a
     page with a way go under that row. */
  .head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
  }
  .head-row > .crumbs,
  html.sd .head-row > .crumbs {
    flex: 0 0 auto;
    max-width: 100%;
    margin: 0;
  }
  .head-row > .top {
    display: contents;
  }
  /* the search has its own row under the way over the whole width on every page, so it is never squeezed and its words are whole (the
     owner's audit 30. 11. 2026: it stood beside a short way and under a long one, cut to „Hledat.“) */
  .head-row .top-tools {
    flex: 1 1 100%;
    width: auto;
    min-width: 0;
    margin: 0;
  }
  /* the narrow field keeps its room for the words: less padding around the magnifier, so that "Hledat…" is whole even at 96 px */
  html.sd .head-row .top-search .filter-input {
    padding: 0 6px 0 10px;
    gap: 4px;
  }
  html.sd .head-row .top-search .filter-input input {
    padding: 0;
    min-width: 0;
  }
  .head-row .top-tools:not(:has(.top-search)) {
    display: contents;
  }
  .head-row .top-left {
    order: 2;
    flex: 1 1 100%;
    min-width: 0;
    margin: 0;
  }
  /* the tabs of the administration wrap to more rows, never out over the right edge */
  .head-row .top-left > .admin-tabs {
    flex-wrap: wrap;
    overflow: visible;
  }
  /* no way (Domů): the quick buttons and the search are one flow, the search fills the rest of their last row */
  .head-row:not(:has(> .crumbs)) .top-left,
  .head-row:not(:has(> .crumbs)) .top-left > .admin-tabs {
    display: contents;
  }

  /* the dark veil over the page */
  .drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 32, 0.5);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.2s ease,
      visibility 0s linear 0.2s;
  }
  .side.open .drawer-scrim {
    opacity: 1;
    visibility: visible;
    transition:
      opacity 0.2s ease,
      visibility 0s;
  }

  /* the card of the menu, sliding in from the left */
  html .side .side-menu {
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1201;
    width: min(320px, 86vw);
    /* the same room above the circles as between them and the first item (gap 14px; the owner, 28. 11. 2026) */
    padding: calc(14px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
    background: var(--menu);
    border-right: 1px solid var(--line);
    border-radius: 0 16px 16px 0;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.24);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    visibility: hidden;
    /* hidden only after it slid out, visible at once (so that the cross can take the focus) */
    transition:
      transform 0.25s ease,
      visibility 0s linear 0.25s;
  }
  html .side.open .side-menu {
    transform: none;
    visibility: visible;
    transition:
      transform 0.25s ease,
      visibility 0s;
  }
  /* the head of the card, made simpler (the owner, 28. 11. 2026): no logo, the circles of the companies on the first line (the chosen one has
     its ring) and the cross on the same line on the right, in the middle of their height */
  html .side .side-menu {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-content: start;
  }
  html .side .side-menu > * {
    grid-column: 1 / -1;
  }
  .drawer-head {
    display: flex;
  }
  /* the same weight as the rule of .companies below: otherwise the rule ".side-menu > *" stretched the head over both columns and the line
     of the circles lay over the cross, which then took no tap */
  html .side .side-menu > .drawer-head {
    grid-column: 2 / 3;
    grid-row: 1;
    align-self: center;
    justify-content: flex-end;
  }
  .drawer-head .logo-pill {
    display: none;
  }
  html .side .side-menu > .companies {
    grid-column: 1 / 2;
    grid-row: 1;
  }
  .side-menu .companies {
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
  }
  .side-menu .nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
  }
  .side-menu .userbox {
    margin: auto 0 0;
    width: 100%;
  }
  /* a person who folded the menu on a computer still gets the whole menu here */
  html.side-off .side-menu .nav a > span:not(.nav-badge),
  html.sd.side-off .side-menu .user-btn .who-name,
  html.sd.side-off .side-menu .user-btn .chev {
    display: revert;
  }
  html.sd.side-off .side-menu .user-btn {
    justify-content: flex-start;
    padding: 8px 10px;
  }
  html.sd.side-off .side-menu .user-pop {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% - 30px);
    width: auto;
  }
  /* the page under the open menu does not scroll */
  html.menu-open,
  html.menu-open body {
    overflow: hidden;
  }
}
/* the slide follows the switch Animační efekty (html[data-fx], which already follows the device when the person chose nothing) */
@media (max-width: 860px) {
  html[data-fx='off'] .side .side-menu,
  html[data-fx='off'] .drawer-scrim {
    transition: none;
  }
}

/* no bar of the scroll in the menu, on a phone or a computer (the owner, 28. 11. 2026): it scrolls by the finger or the wheel, nothing is drawn */
.side,
.side-scroll,
.side-menu {
  scrollbar-width: none;
}
.side::-webkit-scrollbar,
.side-scroll::-webkit-scrollbar,
.side-menu::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Finance: what this application has on top of the shared piece */
@media (max-width: 860px) {
  /* the card has the colour of the menu of the computer, as in INTECHI CRM, not the tint of the company (in the dark mode it was bluer and
     the lines of the groups disappeared on it; the owner, 28. 11. 2026) */
  html.sd .side .side-menu {
    background: var(--sd-color-slate-50);
  }
  html.sd[data-theme='dark'] .side .side-menu {
    background: #0f1720;
  }
  /* the groups of the menu keep their lines in the card, as on a computer */
  .side-menu .nav-sep {
    display: block;
    margin: 6px 10px;
    width: auto;
  }
  /* the user under a line, as on a computer (Demo and O aplikaci are the last group of the menu, under an hr.nav-sep like the others) */
  html.sd .side .side-menu .userbox::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10px;
    right: 10px;
    border-top: 1px solid var(--line);
  }
  /* the line above the user as far from O aplikaci as from the user, 8 px like every line of the menu (the gap of the card is 14 px: it was
     14 px above the line and 9 px under it; the owner, 30. 11. 2026) */
  html.sd .side .side-menu .userbox {
    position: relative;
    margin-top: -6px;
    padding-top: 9px;
  }
  /* the years of the company stand in the row of the way like the quick buttons of CRM: under the way, or beside the search on Domů;
     a page without the years leaves no empty place */
  .head-row > .top > .chips {
    order: 2;
    flex: 1 1 100%;
    min-width: 0;
    margin: 0;
    /* the years wrap to a second row instead of running out over the right edge (the owner's audit 30. 11. 2026) */
    flex-wrap: wrap;
    overflow: visible;
  }
  .head-row:not(:has(> .crumbs)) > .top > .chips {
    order: 0;
    flex: 0 1 auto;
  }
  .head-row > .top > div:empty {
    display: none;
  }
}
