:root { --sidebar-width: 320px; --topbar-height: 52px; --content-offset: var(--sidebar-width); --menu-mode: side; }
/* Desktop with the menu slid out: content uses the full width, the top bar gets the ☰ button */
html.sidebar-collapsed { --content-offset: 0px; }
/* …and pages and tables grow by the width the menu gave up */
main.container { transition: max-width .25s ease; }
html.sidebar-collapsed main.container { max-width: calc(1100px + var(--sidebar-width)); }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-width); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; z-index: 2000; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; color: var(--text); }
.sidebar .brand { display: block; padding: 18px 20px 12px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.sidebar .context { padding: 0 16px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.sidebar .context label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); margin: 0 0 4px; font-weight: 600; }
.sidebar .context select { width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 14px; background: var(--surface); }
.sidebar .context-name { font-weight: 600; color: var(--muted); }
.sidebar nav { flex: 1; padding: 4px 8px; }
.sidebar nav a, .sidebar nav .disabled, .sidebar-footer a, .sidebar-footer button { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; background: none; border: 0; width: 100%; box-sizing: border-box; font: inherit; cursor: pointer; text-align: left; }
.sidebar nav a:hover, .sidebar-footer a:hover, .sidebar-footer button:hover { background: var(--soft); }
.sidebar nav a.active, .sidebar-footer a.active { background: var(--info-bg); color: var(--primary); font-weight: 600; }
.sidebar nav .disabled { color: var(--muted-2); cursor: default; }
.sidebar .icon { flex: none; color: var(--muted); }
.sidebar a.active .icon { color: var(--primary); }
.sidebar nav .disabled .icon { color: #bcccdc; }
.sidebar nav a > span, .sidebar nav .disabled > span, .sidebar-footer a > span, .sidebar-footer button > span {
    flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .tag { flex: none; margin-left: auto; font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 9px; background: var(--track); color: var(--muted-2); }
.sidebar .tag-new { background: #e8590c; color: #fff; font-weight: 600; }
.sidebar .nav-section { margin: 14px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); font-weight: 600; }
/* a group of menu entries (Module, Konto, Plattform): heading above a separating line across the menu */
.sidebar .nav-group { margin: 10px 0 4px; padding: 12px 12px 0; border-top: 1px solid var(--border); }
.sidebar-footer { border-top: 1px solid var(--border); padding: 8px; }
/* the app's version at the very bottom of the menu (only inside the Android app) */
.sidebar-version { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--muted-2); text-decoration: none; text-align: center; }
.sidebar-version:hover, .sidebar-version:active { color: var(--primary); background: var(--soft-2); }
.sidebar-footer .who { display: flex; align-items: center; gap: 10px; padding: 6px 12px 8px; font-size: 13px; color: var(--muted); }
.sidebar-footer .who .who-avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--track); color: var(--text); font-weight: 700; }
.sidebar-footer .who .who-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-footer .who .who-text { min-width: 0; }
.sidebar-footer form { margin: 0; }
.sidebar { transition: transform .25s ease; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding-right: 10px; }
.help-link { display: inline-flex; align-items: center; justify-content: center; padding: 8px; border-radius: 8px; color: var(--muted); flex: none; }
.help-link:hover, .help-link.active { background: var(--soft); color: var(--primary); }
.map-source-tag { margin-left: auto; margin-right: 4px; font-size: 11px; color: var(--muted-2); text-decoration: none; padding: 2px 6px; border: 1px solid var(--border); border-radius: 10px; white-space: nowrap; }
.map-source-tag:hover { color: var(--primary); border-color: #1f6feb; }
.menu-toggle { background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--text); display: inline-flex; }
.menu-toggle:hover { background: var(--soft); }
/* The top bar: always there, with the signed-in user at its right end. Beside the open desktop menu it starts where
   the menu ends and leaves button and name to the menu. */
.mobilebar { display: flex; align-items: center; gap: 8px; position: fixed; top: 0; left: var(--content-offset); right: 0; height: 52px; box-sizing: border-box; transition: left .25s ease;
    background: var(--surface); border-bottom: 1px solid var(--border); z-index: 1900; padding: 0 8px; font-family: system-ui, sans-serif; }
.mobilebar .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.sidebar-backdrop { display: none; }
.menu-toggle .when-narrow { display: none; }
.menu-toggle .when-wide, .menu-toggle .when-narrow { line-height: 0; }
/* The whole button takes the tap, not the three thin lines of the drawing inside it */
.menu-toggle { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.menu-toggle svg, .menu-toggle span { pointer-events: none; }
/* New alarms: a dot on the menu button, visible without opening the menu */
.mobilebar .menu-toggle { position: relative; }
.mobilebar .menu-toggle.has-alert::after { content: ""; position: absolute; top: 8px; right: 7px; width: 11px; height: 11px; border-radius: 50%; background: #c62828; box-shadow: 0 0 0 2px #fff; }
body.with-sidebar { padding-left: var(--content-offset); padding-top: var(--topbar-height); transition: padding-left .25s ease; }

html.sidebar-collapsed .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
html:not(.sidebar-collapsed) .mobilebar > .menu-toggle, html:not(.sidebar-collapsed) .mobilebar > .brand { display: none; }
html.sidebar-collapsed .mobilebar > .bar-context { display: none; }
.mobilebar .bar-context { padding-left: 12px; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.userbar { position: relative; margin-left: auto; flex: none; font-size: 14px; color: var(--text); }
.user-button { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 4px; border: 0; border-radius: 20px; background: none; font: inherit; color: var(--text); cursor: pointer; max-width: 260px; -webkit-tap-highlight-color: transparent; }
.user-button:hover, .user-button[aria-expanded="true"] { background: var(--soft); }
.user-avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--track); color: var(--text); font-weight: 700; font-size: 14px; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.user-caret { flex: none; color: var(--muted-2); transition: transform .15s ease; }
.user-button[aria-expanded="true"] .user-caret { transform: rotate(180deg); }
.user-menu { position: absolute; top: calc(100% + 6px); right: 0; width: 270px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 42, 67, .18); padding: 6px; box-sizing: border-box; }
.user-menu[hidden], .user-backdrop[hidden] { display: none; }
.user-backdrop { position: fixed; inset: 0; }
/* the open account menu above the page's own layers (map panels 2000–3100, toasts 5000, notices 6000) */
html.user-menu-open .mobilebar { z-index: 7000; }
.user-menu-close { display: none; }
.user-menu-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.user-menu-head .user-avatar { width: 44px; height: 44px; font-size: 18px; }
.user-menu-who { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.user-menu-who strong, .user-menu-who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-who small { font-size: 12px; color: var(--muted-2); }
.user-menu form { margin: 0; }
.user-menu a, .user-menu form button { display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; min-height: 40px; padding: 0 10px; border: 0; border-radius: 8px; background: none; font: inherit; color: var(--text); text-decoration: none; text-align: left; cursor: pointer; }
.user-menu a:hover, .user-menu form button:hover { background: var(--soft); }
.user-menu a.active { background: var(--info-bg); color: var(--primary); font-weight: 600; }
.user-menu .icon { flex: none; color: var(--muted); }
.user-menu a.active .icon { color: var(--primary); }

/* Mobile (also a phone held sideways, which is wider than 800 px): the menu slides in over the page. Slim look made for thumbs: rows 48 px high, 16 px text, the current
   page marked by a thin bar, top and bottom fixed while the list scrolls; safe areas of phones with a notch respected */
@media (max-width: 800px), (pointer: coarse) and (max-height: 500px) {
    /* --menu-mode tells the script in nav.blade.php which of the two menus is in use */
    :root, html.sidebar-collapsed { --topbar-height: calc(58px + env(safe-area-inset-top, 0px)); --content-offset: 0px; --menu-mode: over; }
    .mobilebar { left: 0; height: var(--topbar-height); padding: env(safe-area-inset-top, 0px) max(6px, env(safe-area-inset-right, 0px)) 0 max(6px, env(safe-area-inset-left, 0px));
        border-bottom-color: var(--border-soft); gap: 4px; }
    .mobilebar .brand { font-size: 16px; letter-spacing: .01em; }
    /* phone: button and name always in the bar (the menu slides over the page); the user is shown by the picture alone */
    html:not(.sidebar-collapsed) .mobilebar > .menu-toggle { display: inline-flex; }
    html:not(.sidebar-collapsed) .mobilebar > .brand { display: inline; }
    .mobilebar > .bar-context, .user-name, .user-caret { display: none; }
    .user-button { height: 48px; padding: 0 8px; }
    .user-avatar { width: 36px; height: 36px; }
    /* the account menu comes up from the bottom as a sheet over the dimmed page, with a grip and a close button */
    .user-backdrop { background: rgba(16, 42, 67, .32); animation: user-fade .2s ease; }
    .user-menu { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; font-size: 16px; border: 0; border-radius: 18px 18px 0 0;
        padding: 6px 8px max(12px, env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 40px rgba(16, 42, 67, .22); animation: user-sheet .24s cubic-bezier(.3, .7, .3, 1); }
    .user-menu::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--track); margin: 4px auto 6px; }
    .user-menu-head { padding: 8px 8px 14px 12px; }
    .user-menu-head .user-avatar { width: 52px; height: 52px; font-size: 20px; }
    .user-menu-who { flex: 1; }
    .user-menu-who strong { font-size: 17px; }
    .user-menu-who small { font-size: 13px; }
    .user-menu-close { display: inline-flex; align-items: center; justify-content: center; flex: none; align-self: flex-start; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--soft); color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent; }
    .user-menu a, .user-menu form button { min-height: 52px; padding: 0 12px; gap: 16px; border-radius: 12px; }
    .user-menu a:hover, .user-menu form button:hover { background: none; }
    .user-menu a:active, .user-menu form button:active { background: var(--soft-2); }
    .user-menu a.active { background: var(--info-bg); }
    .user-menu form { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-soft); }
    .user-menu form button { color: var(--danger); }
    .user-menu form button .icon { color: var(--danger); }
    .menu-toggle { flex: none; width: 56px; height: 52px; padding: 0; align-items: center; justify-content: center; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
    .menu-toggle:hover { background: none; }
    .menu-toggle:active { background: #eef2f6; }
    .menu-toggle .icon { width: 32px; height: 32px; stroke-width: 2; }
    /* Tap area larger than the visible button: to the screen edge, to the top, and a little below the bar */
    .mobilebar .menu-toggle::before { content: ""; position: absolute; top: -8px; left: -12px; right: -6px; bottom: -14px; }
    .mobilebar { overflow: visible; }
    .menu-toggle .when-wide { display: none; }
    .menu-toggle .when-narrow { display: inline; }
    /* the icons on the right (help, search, account): one size, 44 px round with 24 px icons, a grey circle when tapped,
       a little room between them; the name gives way on narrow phones */
    .mobilebar { gap: 6px; }
    .mobilebar .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobilebar .help-link, .mobilebar .gsearch-open { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: none; -webkit-tap-highlight-color: transparent; }
    .mobilebar .help-link .icon, .mobilebar .gsearch-open .icon { width: 24px; height: 24px; stroke-width: 2; }
    .mobilebar .help-link:hover, .mobilebar .gsearch-open:hover { background: none; }
    .mobilebar .help-link:active, .mobilebar .gsearch-open:active, .mobilebar .user-button:active { background: var(--soft); }
    .mobilebar .help-link.active { background: var(--info-bg); }
    .mobilebar .user-button { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 50%; }
    .mobilebar .user-button:hover { background: none; }
    .mobilebar .user-avatar { width: 40px; height: 40px; font-size: 16px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }

    .sidebar, html.sidebar-collapsed .sidebar { width: min(330px, 86vw); transform: translateX(-100%); visibility: hidden; overflow: hidden;
        transition: transform .22s cubic-bezier(.3, .7, .3, 1), visibility 0s .22s; border-right: 0; box-shadow: none; font-size: 16px;
        padding-left: env(safe-area-inset-left, 0px); overscroll-behavior: contain; }
    body.sidebar-open .sidebar, html.sidebar-collapsed body.sidebar-open .sidebar { transform: none; visibility: visible;
        transition: transform .22s cubic-bezier(.3, .7, .3, 1); box-shadow: 0 0 40px rgba(16, 42, 67, .18); }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(16, 42, 67, .32); z-index: 1950; opacity: 0; pointer-events: none; transition: opacity .22s ease; }
    body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
    body.sidebar-open { overflow: hidden; }

    .sidebar-head { flex: none; height: var(--topbar-height); padding: env(safe-area-inset-top, 0px) 6px 0 0; border-bottom: 1px solid var(--border-soft); }
    .sidebar .brand { padding: 0 20px; font-size: 16px; letter-spacing: .01em; }
    .sidebar .context { flex: none; padding: 12px 16px; margin: 0; border-bottom: 1px solid var(--border-soft); }
    .sidebar .context select { height: 44px; padding: 0 10px; font-size: 16px; border-color: var(--border); border-radius: 10px; background: var(--soft-2); }

    /* scrolls up and down only: setting overflow-y alone would also allow sideways scrolling */
    .sidebar nav { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px 0; }
    .sidebar nav a, .sidebar nav .disabled, .sidebar-footer a, .sidebar-footer button { position: relative; min-height: 48px; padding: 0 20px; gap: 16px;
        border-radius: 0; color: var(--text); -webkit-tap-highlight-color: transparent; }
    .sidebar nav a:hover, .sidebar-footer a:hover, .sidebar-footer button:hover { background: none; }
    .sidebar nav a:active, .sidebar-footer a:active, .sidebar-footer button:active { background: var(--soft-2); }
    .sidebar nav a.active, .sidebar-footer a.active { background: none; color: var(--primary); font-weight: 600; }
    .sidebar nav a.active::before, .sidebar-footer a.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: #1f6feb; }
    .sidebar .icon { width: 22px; height: 22px; color: var(--muted-2); stroke-width: 1.6; }
    .sidebar .tag { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--soft-2); color: var(--muted-2); }
    .sidebar .tag-count { min-width: 22px; text-align: center; }
    .sidebar .nav-section { margin: 10px 0 0; padding: 14px 20px 6px; box-sizing: border-box; max-width: 100%; border-top: 1px solid var(--border-soft); color: var(--muted-2); font-weight: 500; letter-spacing: .08em; }

    .sidebar-footer { flex: none; padding: 4px 0 max(6px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border-soft); background: var(--surface); }
    .sidebar-footer .who { padding: 10px 20px 4px; font-size: 13px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .sidebar-footer .who .who-text { overflow: hidden; text-overflow: ellipsis; }
    .sidebar-footer .who .who-text span { color: var(--text); font-weight: 600; }
    .sidebar-footer .who br { display: none; }
    .sidebar-footer .who small { font-size: inherit; }
    .sidebar-footer .who small::before { content: " · "; }
    .sidebar-footer a, .sidebar-footer button { min-height: 44px; }
}
/* Low phones (landscape): the bottom entries scroll with the list instead of taking half the screen */
@media (max-width: 800px) and (max-height: 520px), (pointer: coarse) and (max-height: 500px) {
    .sidebar, html.sidebar-collapsed .sidebar { overflow-y: auto; overflow-x: hidden; }
    .sidebar nav { flex: none; overflow: visible; }
}
/* Notice shown when the app is opened (e.g. a licence check is due): a card at the bottom of the screen */
/* New app version (app-bridge.js): full screen over the dimmed, blurred page */
.appup { position: fixed; inset: 0; z-index: 8000; display: flex; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box;
    background: rgba(10, 20, 35, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: appup-fade .25s ease; }
.appup[hidden] { display: none; }
html.appup-open, html.appup-open body { overflow: hidden; }
.appup-card { width: 100%; max-width: 420px; max-height: calc(100vh - 40px); overflow-y: auto; box-sizing: border-box; padding: 28px 22px 20px; border-radius: 20px;
    background: var(--surface); color: var(--text); text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); animation: appup-rise .3s cubic-bezier(.2, .8, .2, 1); }
.appup-icon { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; font-size: 36px; background: var(--info-bg); }
.appup-card h2 { margin: 0 0 8px; font-size: 20px; line-height: 1.3; }
.appup-text { margin: 0; color: var(--muted); font-size: 15px; }
.appup-notes { margin: 14px 0 0; padding: 12px 14px 12px 32px; text-align: left; font-size: 14.5px; border-radius: 12px; background: var(--soft-2); }
.appup-notes[hidden] { display: none; }
.appup-notes li + li { margin-top: 6px; }
.appup-go { display: flex; align-items: center; justify-content: center; min-height: 52px; margin-top: 20px; border-radius: 12px; background: var(--primary); color: var(--primary-text);
    font-size: 17px; font-weight: 700; text-decoration: none; }
.appup-later { display: block; width: 100%; min-height: 46px; margin-top: 8px; border: 0; border-radius: 12px; background: none; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.appup-later:active { background: var(--soft-2); }
@keyframes appup-fade { from { opacity: 0; } }
@keyframes appup-rise { from { opacity: 0; transform: translateY(24px) scale(.97); } }
@media (prefers-reduced-motion: reduce) { .appup, .appup-card { animation: none; } }
.app-notice { position: fixed; z-index: 1960; right: 16px; bottom: 16px; width: 380px; max-width: calc(100vw - 32px); box-sizing: border-box; display: grid; grid-template-columns: auto 1fr; gap: 10px 12px;
    padding: 14px 14px 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid #e8590c; border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 42, 67, .2);
    font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); animation: user-sheet .24s cubic-bezier(.3, .7, .3, 1); }
.app-notice[hidden] { display: none; }
.app-notice.is-late { border-left-color: #c62828; }
.app-notice-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--warn-bg); color: #e8590c; }
.app-notice.is-late .app-notice-icon { background: var(--danger-bg); color: var(--danger); }
.app-notice-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-notice-text strong { font-size: 15px; }
.app-notice-text span { color: var(--muted); }
.app-notice-text span + strong { margin-top: 8px; }
.app-notice-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.app-notice-actions a, .app-notice-actions button { display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.app-notice-later { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.app-notice-go { border: 0; background: #1f6feb; color: #fff; }
@media (max-width: 800px), (pointer: coarse) and (max-height: 500px) {
    .app-notice { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom, 0px)); width: auto; max-width: none; font-size: 15px; }
    .app-notice-actions a, .app-notice-actions button { min-height: 44px; flex: 1; justify-content: center; }
}
html[dir="rtl"] .app-notice { direction: rtl; border-left-width: 1px; border-right: 4px solid #e8590c; }
html[dir="rtl"] .app-notice.is-late { border-right-color: #c62828; }
@keyframes user-sheet { from { transform: translateY(100%); } }
@keyframes user-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .user-menu, .user-backdrop { animation: none !important; } }
@media (prefers-reduced-motion: reduce) { .sidebar, body.with-sidebar, #mapShell { transition: none !important; } }

/* Right-to-left languages (Arabic): texts and lists run from the right. The menu stays on the left and the map keeps
   its own geometry, so nothing has to be measured again; only what is aligned by hand is turned. */
html[dir="rtl"] .sidebar nav a, html[dir="rtl"] .sidebar nav .disabled, html[dir="rtl"] .sidebar-footer a, html[dir="rtl"] .sidebar-footer button { text-align: right; }
html[dir="rtl"] .sidebar .tag { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .leaflet-container { direction: ltr; }
html[dir="rtl"] .leaflet-container .leaflet-tooltip, html[dir="rtl"] .leaflet-container .leaflet-popup-content, html[dir="rtl"] .vehicle-marker .vm-label { direction: rtl; }
html[dir="rtl"] th, html[dir="rtl"] td, html[dir="rtl"] .menu-list button { text-align: right; }
html[dir="rtl"] .num, html[dir="rtl"] th.num, html[dir="rtl"] td.num { text-align: left; }
html[dir="rtl"] .mono, html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="password"], html[dir="rtl"] input[inputmode="numeric"] { direction: ltr; text-align: right; }
/* the bar keeps its order (menu button left, user right); the account menu itself reads from the right */
html[dir="rtl"] .mobilebar { direction: ltr; }
html[dir="rtl"] .user-menu { direction: rtl; }
html[dir="rtl"] .user-menu a, html[dir="rtl"] .user-menu form button { text-align: right; }

/* Search in the top bar (layouts/nav, js/global-search.js): a field in the middle of the bar; on phones a button
   that lays the field over the bar and the hits over the page */
.gsearch { position: relative; flex: 1 1 auto; max-width: 460px; min-width: 0; margin-left: auto; }
.gsearch-open, .gsearch-close { display: none; background: none; border: 0; padding: 8px; border-radius: 8px; color: var(--text); cursor: pointer; line-height: 0; }
.gsearch-open:hover, .gsearch-close:hover { background: var(--soft); }
.gsearch-box { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 19px; background: var(--soft-2); color: var(--muted-2); box-sizing: border-box; }
.gsearch-box:focus-within { background: var(--surface); border-color: #1f6feb; box-shadow: 0 0 0 3px rgba(31, 111, 235, .15); }
.gsearch-box .icon { flex: none; }
.mobilebar .gsearch-box input { flex: 1; min-width: 0; width: auto; border: 0; outline: 0; box-shadow: none; background: none; font: inherit; font-size: 15px; color: var(--text); padding: 0; margin: 0; height: 100%; border-radius: 0; }
.gsearch-box input::-webkit-search-cancel-button { cursor: pointer; }
.gsearch-key { flex: none; font: 600 11px/1 system-ui, sans-serif; color: var(--muted-2); border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; background: var(--surface); }
.gsearch-box:focus-within .gsearch-key { display: none; }
.gsearch-results { position: absolute; top: calc(100% + 6px); left: 0; width: max(100%, 420px); max-width: calc(100vw - 16px); max-height: min(70vh, 560px); overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 42, 67, .18); padding: 6px; box-sizing: border-box; z-index: 1950; }
.gsearch-results[hidden] { display: none; }
.gs-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.gs-row { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.gs-row.is-active, .gs-row:hover { background: var(--info-bg); }
.gs-hit { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; color: var(--text); text-decoration: none; }
.gs-hit strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-hit small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-hit mark { background: #fff3bf; color: inherit; border-radius: 2px; }
.gs-edit { flex: none; display: inline-flex; padding: 8px; margin-right: 4px; border-radius: 8px; color: var(--muted); line-height: 0; }
.gs-edit:hover { background: #d9e8fb; color: var(--primary); }
.gs-more { display: block; padding: 6px 10px 8px; font-size: 13px; color: var(--primary); text-decoration: none; }
.gs-more:hover { text-decoration: underline; }
.gs-empty { padding: 14px 10px; color: var(--muted); font-size: 14px; }
@media (max-width: 800px), (pointer: coarse) and (max-height: 500px) {
    .gsearch { flex: none; margin-left: auto; position: static; }
    .gsearch + .userbar { margin-left: 0; }
    .gsearch-open { display: inline-flex; }
    .gsearch-box, .gsearch-key { display: none; }
    .gsearch.is-open .gsearch-box { display: flex; position: fixed; z-index: 1960; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: calc(var(--topbar-height) - env(safe-area-inset-top, 0px));
        border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: var(--surface); box-shadow: none; padding: 0 max(6px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px)); }
    .mobilebar .gsearch.is-open .gsearch-box input { font-size: 16px; }
    .gsearch.is-open .gsearch-close { display: inline-flex; }
    .gsearch-results { position: fixed; top: var(--topbar-height); left: 0; right: 0; bottom: 0; width: auto; max-width: none; max-height: none; border: 0; border-radius: 0; box-shadow: none;
        padding: 6px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px)); }
    .gs-hit { padding: 11px 10px; }
    .gs-edit { padding: 12px; }
    /* phones, the app and the web app: a big search button, a framed field across the bar, results easy to tap */
    .gsearch-open { width: 44px; height: 44px; padding: 0; align-items: center; justify-content: center; border-radius: 50%; }
    .gsearch-open .icon { width: 24px; height: 24px; }
    .gsearch.is-open .gsearch-box { gap: 6px; padding-top: 6px; padding-bottom: 6px; align-items: center; }
    .gsearch.is-open .gsearch-box > .icon { display: none; }
    .mobilebar .gsearch.is-open .gsearch-box input { -webkit-appearance: none; appearance: none; height: 44px; padding: 0 14px 0 42px; border: 1px solid var(--border); border-radius: 22px; background: var(--soft-2) no-repeat 14px center / 20px
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8794' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
    html[dir="rtl"] .mobilebar .gsearch.is-open .gsearch-box input { padding: 0 42px 0 14px; background-position: right 14px center; }
    .mobilebar .gsearch.is-open .gsearch-box input:focus { border-color: #1f6feb; background-color: var(--surface); box-shadow: 0 0 0 3px rgba(31, 111, 235, .15); }
    .gsearch.is-open .gsearch-close { width: 44px; height: 44px; padding: 0; align-items: center; justify-content: center; border-radius: 50%; flex: none; }
    .gsearch.is-open .gsearch-close .icon { width: 22px; height: 22px; }
    .gs-group { padding: 14px 12px 6px; font-size: 12.5px; }
    .gs-row { min-height: 56px; }
    .gs-hit { padding: 12px; gap: 3px; }
    .gs-hit strong { font-size: 16px; }
    .gs-hit small { font-size: 13.5px; }
    .gs-edit { width: 44px; height: 44px; padding: 0; align-items: center; justify-content: center; }
    .gs-more { padding: 14px 12px; font-size: 15px; font-weight: 600; }
    .gs-empty { padding: 20px 12px; font-size: 15px; }
}
@media print { .gsearch { display: none; } }
