/* MG — התאמה לטלפון וטאבלט (דפי public + index) */
html {
  -webkit-text-size-adjust: 100%;
}

img,
video {
  max-width: 100%;
  height: auto;
}

.mg-table-scroll,
table.mg-responsive-table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .wrap {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  header {
    flex-direction: column;
    align-items: stretch !important;
  }

  .grid.cards,
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .row2 {
    grid-template-columns: 1fr !important;
  }

  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* מערכת ראשית (index.html) */
@media (max-width: 1024px) {
  .mg-app-shell {
    flex-direction: column;
  }

  .sidebar,
  .sidebar-right {
    width: 100% !important;
    max-height: 38vh;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--mg-border, #454545);
  }

  .mg-toolbar-band .header-actions-group {
    flex-wrap: wrap;
    max-height: none;
  }

  .header {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 6px;
  }

  .mg-header-center,
  .mg-header-left-corner {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  #landingPage .max-w-6xl {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .landing-hero-logo {
    width: 160px !important;
  }

  #landingCardsGrid > [data-landing-card] {
    min-height: 160px !important;
    padding: 1.25rem !important;
  }
}

/* —— בורר תצוגה: מחשב / טאבלט / טלפון —— */
.mg-device-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.mg-device-switch button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

.mg-device-switch button span {
  display: none;
}

.mg-device-switch button:hover {
  color: #e2e8f0;
  background: rgba(56, 189, 248, 0.12);
}

.mg-device-switch button.active,
.mg-device-switch button.auto-active {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

@media (min-width: 640px) {
  .mg-device-switch button span {
    display: inline;
  }
}

.gis-projects-toolbar {
  width: min(920px, 95vw);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.gis-projects-toolbar .search-wrap {
  flex: 1;
  min-width: min(100%, 280px);
  margin-bottom: 0 !important;
}

/* —— דף בחירת פרויקט GIS (/gis/) —— */
html.mg-device-tablet .gis-projects-wrap,
html.mg-device-mobile .gis-projects-wrap {
  padding: 20px 12px !important;
}

html.mg-device-tablet .gis-projects-grid,
html.mg-device-mobile .gis-projects-grid {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
  gap: 14px !important;
}

html.mg-device-mobile .gis-projects-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

html.mg-device-mobile .gis-projects-header h1 {
  font-size: 1.25rem !important;
}

html.mg-device-mobile .proj-card {
  max-width: none !important;
  padding: 12px 8px !important;
}

html.mg-device-mobile .proj-logo,
html.mg-device-mobile .proj-logo-placeholder {
  width: 56px !important;
  height: 56px !important;
}

@media (max-width: 900px) {
  .gis-projects-wrap {
    padding: 20px 12px !important;
  }

  .gis-projects-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
  }
}

@media (max-width: 480px) {
  .gis-projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* —— מערכת GIS (project-v /gis/app/) —— */
html.mg-device-tablet #mapContainer,
html.mg-device-mobile #mapContainer {
  top: 8px;
  bottom: 8px;
  left: 8px;
  right: 8px;
  flex-direction: column;
}

html.mg-device-tablet #rightSidebar,
html.mg-device-mobile #rightSidebar {
  width: 100%;
  max-height: 42vh;
  border-left: none;
  border-bottom: 1px solid #cbd5e0;
  overflow-y: auto;
}

html.mg-device-tablet #sidebarButtons,
html.mg-device-mobile #sidebarButtons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

html.mg-device-tablet #sidebarButtons button,
html.mg-device-mobile #sidebarButtons button {
  margin-bottom: 0;
  font-size: 12px;
  padding: 8px 10px;
}

html.mg-device-tablet #gisFiltersPanel,
html.mg-device-mobile #gisFiltersPanel {
  left: 8px !important;
  right: 8px !important;
  top: auto !important;
  bottom: 72px !important;
  width: auto !important;
  max-width: none !important;
}

html.mg-device-tablet #customSearchMenu,
html.mg-device-tablet .mg-settlement-menu,
html.mg-device-mobile #customSearchMenu,
html.mg-device-mobile .mg-settlement-menu {
  right: 8px !important;
  left: 8px !important;
  width: auto !important;
  max-width: none !important;
}

html.mg-device-tablet #gisSidebarToggle,
html.mg-device-mobile #gisSidebarToggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

html.mg-device-tablet body.gis-sidebar-collapsed #rightSidebar,
html.mg-device-mobile body.gis-sidebar-collapsed #rightSidebar {
  display: none;
}

html.mg-device-mobile #sidebarButtons {
  grid-template-columns: 1fr;
}

html.mg-device-tablet #floatingSettingsBtn,
html.mg-device-mobile #floatingSettingsBtn {
  bottom: 16px;
  left: 16px;
}

html.mg-device-tablet #floatingScaleBtn,
html.mg-device-mobile #floatingScaleBtn {
  bottom: 16px;
  left: 72px;
}

html.mg-device-mobile #gisDeviceBarHost {
  top: 8px;
  left: 8px;
  right: 8px;
}

#gisDeviceBarHost {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10060;
}

/* —— דף נחיתה (כרטיסי קישורים) —— */
#landingPage,
#landingPage.landing-page-root {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  align-items: center !important;
  justify-content: flex-start !important;
  padding-top: 3.25rem;
  padding-bottom: 2.5rem;
  min-height: 100vh;
  min-height: 100dvh;
  max-height: 100dvh;
  height: 100%;
  box-sizing: border-box;
}

.landing-device-bar-host {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20001;
}

.landing-scroll-nav {
  z-index: 20002;
}

.landing-scroll-range-row {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: min(72rem, 96vw);
  margin: 0 auto 0.35rem;
  padding: 0 0.25rem;
  font-size: 0.72rem;
  color: #94a3b8;
  flex-shrink: 0;
}

.landing-scroll-range-label {
  white-space: nowrap;
  font-weight: 700;
}

.landing-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 rgba(15, 23, 42, 0.85);
  padding-bottom: 0.5rem;
}

#landingCardsGrid > [data-landing-card] {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

#landingCardsGrid a[data-landing-card] {
  text-decoration: none;
  color: inherit;
}

#landingPage .landing-page-inner,
#landingPage .max-w-6xl {
  margin-bottom: 1rem;
  width: 100%;
  max-width: min(72rem, 96vw);
  box-sizing: border-box;
}

#landingCardsGrid {
  width: 100%;
  padding-bottom: 2rem;
  align-items: stretch;
  grid-auto-rows: 1fr;
}

/* כרטיסי דף הבית — גודל אחיד */
#landingCardsGrid > [data-landing-card] {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100%;
  min-height: 180px !important;
  box-sizing: border-box;
  padding: 1.35rem 1.15rem !important;
}

#landingCardsGrid > [data-landing-card] h2 {
  font-size: 1.15rem !important;
  line-height: 1.3 !important;
  margin: 0 !important;
  text-align: center;
  flex: 0 0 auto;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* שמירת מקום לשורת «העתק קישור» בכרטיסים ללא כפתור */
#landingCardsGrid > [data-landing-card]:not(:has(button.text-xs))::after {
  content: "";
  display: block;
  flex-shrink: 0;
  min-height: 1.65rem;
  width: 100%;
}

#landingCardsGrid > [data-landing-card] > .w-16,
#landingCardsGrid > [data-landing-card] > div.w-16 {
  flex-shrink: 0;
  margin-top: 0 !important;
  margin-bottom: 0.65rem !important;
}

#landingCardsGrid > [data-landing-card] button.text-xs {
  margin-top: 0.45rem !important;
  margin-bottom: 0 !important;
  flex-shrink: 0;
  line-height: 1.2;
}

#landingCardsGrid.landing-cards-few {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
}

#landingCardsGrid.landing-cards-few > [data-landing-card] {
  flex: none !important;
  max-width: none !important;
  width: auto !important;
  height: 100%;
  min-height: 180px;
}

@media (min-width: 1024px) {
  #landingCardsGrid:not(.landing-cards-few) {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
}

/* מחשב — התאמה לתצוגה 100% (גובה מסך מלא, בלי גלילה מיותרת) */
@media (min-width: 901px) {
  #landingPage.landing-page-root {
    padding-top: 2.75rem;
    padding-bottom: 0.35rem;
    overflow: hidden !important;
    height: 100dvh;
    max-height: 100dvh;
  }

  #landingPage .landing-page-inner {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 3rem);
    max-height: calc(100dvh - 3rem);
    min-height: 0;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
    box-sizing: border-box;
  }

  #landingPage .landing-scroll-range-row {
    display: flex;
  }

  #landingPage .landing-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }

  #landingPage .landing-hero-section {
    flex: 0 0 auto;
    margin-bottom: 0.35rem !important;
    gap: 1rem !important;
  }

  #landingPage .landing-hero-logo-wrap {
    padding: 10px 16px !important;
  }

  #landingPage .landing-hero-logo {
    width: auto !important;
    max-width: min(200px, 28vw) !important;
    max-height: min(120px, 14vh) !important;
    height: auto !important;
  }

  #landingCardsGrid {
    flex: 0 0 auto;
    min-height: 0;
    height: auto;
    margin-top: 0 !important;
    gap: clamp(0.5rem, 1vh, 0.85rem) !important;
    padding-bottom: 0.35rem !important;
    overflow: visible;
    align-content: start;
    align-items: stretch;
    grid-auto-rows: auto;
    grid-template-rows: none;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  #landingCardsGrid > [data-landing-card] {
    min-height: clamp(140px, 15vh, 175px) !important;
    max-height: none !important;
    height: auto !important;
    padding: clamp(0.55rem, 1.2vh, 0.85rem) clamp(0.65rem, 1.4vw, 1rem) !important;
  }

  #landingCardsGrid > [data-landing-card] h2 {
    font-size: clamp(0.88rem, 1.5vh, 1.1rem) !important;
    line-height: 1.25 !important;
  }

  #landingCardsGrid > [data-landing-card] .w-16 {
    width: clamp(2.25rem, 5vh, 2.75rem) !important;
    height: clamp(2.25rem, 5vh, 2.75rem) !important;
    margin-bottom: 0.35rem !important;
  }

  #landingCardsGrid > [data-landing-card] .h-8,
  #landingCardsGrid > [data-landing-card] .w-8 {
    width: clamp(1.1rem, 2.5vh, 1.35rem) !important;
    height: clamp(1.1rem, 2.5vh, 1.35rem) !important;
  }

  #landingPage .landing-site-footer {
    flex: 0 0 auto;
    margin-top: 0.35rem !important;
    padding-top: 0.5rem !important;
    font-size: 0.72rem;
    line-height: 1.35;
  }

  #landingPage .landing-site-footer p {
    margin: 0.15rem 0;
  }

  #landingPage .landing-help-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
  }

  #landingPage .footer-mg-logo {
    max-height: 28px;
    width: auto;
  }
}

html.mg-device-desktop #landingPage.landing-page-root {
  padding-top: 2.75rem;
  padding-bottom: 0.35rem;
  overflow: hidden !important;
  height: 100dvh;
  max-height: 100dvh;
}

html.mg-device-desktop #landingPage .landing-page-inner {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 3rem);
  max-height: calc(100dvh - 3rem);
  min-height: 0;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
  overflow: hidden;
}

html.mg-device-desktop #landingPage .landing-scroll-range-row {
  display: flex;
}

html.mg-device-desktop #landingPage .landing-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

html.mg-device-desktop #landingPage .landing-hero-section {
  flex: 0 0 auto;
  margin-bottom: 0.35rem !important;
}

html.mg-device-desktop .landing-hero-logo {
  max-height: min(120px, 14vh) !important;
  width: auto !important;
  max-width: min(200px, 28vw) !important;
  height: auto !important;
}

html.mg-device-desktop #landingCardsGrid {
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
  margin-top: 0 !important;
  gap: clamp(0.45rem, 1vh, 0.75rem) !important;
  overflow: visible;
  align-items: stretch;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  grid-auto-rows: auto;
}

html.mg-device-desktop #landingCardsGrid > [data-landing-card] {
  min-height: clamp(140px, 15vh, 175px) !important;
  height: auto !important;
  padding: clamp(0.55rem, 1.2vh, 0.9rem) clamp(0.65rem, 1.4vw, 1rem) !important;
}

/* מסכים נמוכים (למשל 1366×768 ב-100%) — דחיסה נוספת */
@media (min-width: 901px) and (max-height: 820px) {
  #landingPage .landing-hero-logo {
    max-height: 10vh !important;
    max-width: 160px !important;
  }

  #landingCardsGrid > [data-landing-card] h2 {
    font-size: 0.9rem !important;
  }

  #landingPage .landing-site-footer {
    margin-top: 0.2rem !important;
    padding-top: 0.35rem !important;
    transform: scale(0.9);
    transform-origin: center bottom;
  }
}

@media (min-width: 901px) and (max-height: 700px) {
  #landingPage .landing-hero-section {
    margin-bottom: 0.15rem !important;
  }

  #landingCardsGrid {
    gap: 0.35rem !important;
  }
}

html.mg-device-tablet #landingPage,
html.mg-device-mobile #landingPage {
  padding-top: 3.5rem;
  padding-left: 10px;
  padding-right: 10px;
  padding-bottom: 4.5rem;
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
}

html.mg-device-tablet #landingPage .landing-page-inner,
html.mg-device-mobile #landingPage .landing-page-inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
  overflow: hidden;
}

html.mg-device-tablet #landingPage .landing-scroll-body,
html.mg-device-mobile #landingPage .landing-scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
}

html.mg-device-tablet #landingPage .landing-scroll-range-row,
html.mg-device-mobile #landingPage .landing-scroll-range-row {
  display: none !important;
}

html.mg-device-tablet .landing-scroll-nav,
html.mg-device-mobile .landing-scroll-nav {
  display: none !important;
}

html.mg-device-tablet .landing-scroll-nav-btn,
html.mg-device-mobile .landing-scroll-nav-btn {
  display: none !important;
}

@media (max-width: 900px) {
  #landingPage.landing-page-root {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
    padding-bottom: 1rem;
  }

  #landingPage .landing-page-inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: hidden;
  }

  #landingPage .landing-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
  }

  #landingPage .landing-scroll-range-row {
    display: none !important;
  }

  #landingScrollNav.landing-scroll-nav {
    display: none !important;
  }
}

html.mg-device-mobile #landingPage .landing-page-inner,
html.mg-device-mobile #landingPage .fade-in {
  padding-left: 10px !important;
  padding-right: 10px !important;
}

html.mg-device-mobile #landingCardsGrid {
  grid-template-columns: 1fr !important;
  gap: 0.85rem !important;
}

html.mg-device-mobile #landingCardsGrid > [data-landing-card] {
  min-height: 128px !important;
  padding: 1rem !important;
}

html.mg-device-mobile #landingCardsGrid > [data-landing-card] h2 {
  font-size: 1.1rem !important;
}

html.mg-device-mobile .landing-hero-logo-wrap {
  padding: 10px 14px !important;
}

html.mg-device-mobile .landing-hero-logo {
  width: 140px !important;
  max-height: 18vh;
}

html.mg-device-tablet #landingCardsGrid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

@media (max-width: 640px) {
  #landingPage .fade-in,
  #landingPage .landing-page-inner {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #landingCardsGrid > [data-landing-card] {
    min-height: 130px !important;
    padding: 1.1rem !important;
  }

  #landingCardsGrid > [data-landing-card] h2 {
    font-size: 1.1rem !important;
  }

  .landing-hero-logo-wrap {
    padding: 12px 16px !important;
  }
}

/* —— מערכת פרויקטים (index.html) —— */
.projects-device-bar-host {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-inline-start: 6px;
}

/* מחשב — מסך ניהול פרויקטים ב-100% (גובה חלון מלא, בלי גלילת דף) */
@media (min-width: 901px) {
  html,
  body.overflow-hidden {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.overflow-hidden > header.header {
    flex: 0 0 auto;
    min-height: 0;
    max-height: 46px;
    padding: 2px 10px;
    gap: 6px;
  }

  body.overflow-hidden > .mg-app-shell {
    flex: 1 1 0;
    min-height: 0;
    height: 0;
    max-height: none;
    overflow: hidden;
    align-items: stretch;
  }

  body.overflow-hidden .sidebar,
  body.overflow-hidden .sidebar-right {
    width: clamp(190px, 14vw, 220px) !important;
    min-width: 190px;
    max-width: 220px;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
  }

  body.overflow-hidden .sidebar #left-content,
  body.overflow-hidden .sidebar-right > div:not(:first-child) {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.overflow-hidden .mg-center-column {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body.overflow-hidden .mg-toolbar-band {
    flex: 0 0 auto;
    min-height: 74px;
    max-height: none;
    overflow-x: visible;
    overflow-y: visible;
    z-index: 120;
  }

  body.overflow-hidden .mg-toolbar-band .header-actions-group {
    height: auto;
    max-height: none;
    min-width: 0;
    width: 100%;
    overflow-x: visible;
    overflow-y: visible;
  }

  body.overflow-hidden .mg-gis-toolbar {
    flex-wrap: nowrap !important;
    min-height: clamp(56px, 11vh, 72px) !important;
    max-height: none;
    width: 100%;
    min-width: 0;
    padding: 2px 4px 2px !important;
    align-items: center !important;
    overflow-x: visible;
    overflow-y: visible;
  }

  body.overflow-hidden .mg-toolbar-flex-mid {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-shrink: 0 !important;
    min-width: 0;
    align-items: center !important;
    flex-wrap: nowrap;
    overflow: visible !important;
  }

  /* גלילת סרגל — רק טאבלט / טלפון */
  html.mg-device-tablet body.overflow-hidden .mg-toolbar-band,
  html.mg-device-mobile body.overflow-hidden .mg-toolbar-band {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  html.mg-device-tablet body.overflow-hidden .mg-toolbar-band .header-actions-group,
  html.mg-device-mobile body.overflow-hidden .mg-toolbar-band .header-actions-group {
    min-width: min-content;
    overflow-x: visible;
  }

  html.mg-device-tablet body.overflow-hidden .mg-gis-toolbar,
  html.mg-device-mobile body.overflow-hidden .mg-gis-toolbar {
    width: max-content;
    min-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* מחשב — כל הכפתורים ללא סליידר, דחיסה קלה */
  html.mg-device-desktop body.overflow-hidden .mg-gis-toolbar .mg-tb-btn,
  html.mg-device-desktop body.overflow-hidden .mg-gis-toolbar-group--compact .mg-tb-btn {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 58px !important;
    height: 58px !important;
    padding: 2px 0 !important;
  }

  html.mg-device-desktop body.overflow-hidden .mg-gis-toolbar .mg-tb-icon,
  html.mg-device-desktop body.overflow-hidden .mg-tb-btn--project-logo .mg-tb-icon {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    font-size: 20px !important;
  }

  html.mg-device-desktop body.overflow-hidden .mg-toolbar-coords {
    width: 188px !important;
    min-width: 188px !important;
    max-width: 188px !important;
    font-size: 11px !important;
  }

  html.mg-device-desktop body.overflow-hidden .mg-asset-field-col {
    width: 108px !important;
  }

  html:not(.mg-device-tablet):not(.mg-device-mobile) body.overflow-hidden .mg-toolbar-band {
    overflow-x: visible !important;
  }

  html:not(.mg-device-tablet):not(.mg-device-mobile) body.overflow-hidden .mg-gis-toolbar {
    overflow-x: visible !important;
    width: 100% !important;
  }

  html:not(.mg-device-tablet):not(.mg-device-mobile) body.overflow-hidden .mg-gis-toolbar .mg-tb-btn,
  html:not(.mg-device-tablet):not(.mg-device-mobile) body.overflow-hidden .mg-gis-toolbar-group--compact .mg-tb-btn {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 58px !important;
    height: 58px !important;
    padding: 2px 0 !important;
  }

  html:not(.mg-device-tablet):not(.mg-device-mobile) body.overflow-hidden .mg-toolbar-coords {
    width: 188px !important;
    min-width: 188px !important;
    max-width: 188px !important;
  }

  body.overflow-hidden .mg-toolbar-fixed-start,
  body.overflow-hidden .mg-toolbar-fixed-end {
    display: flex !important;
    align-items: center !important;
    flex-shrink: 0;
    gap: 0;
  }

  body.overflow-hidden .mg-gis-toolbar-group,
  body.overflow-hidden .mg-toolbar-coords-group,
  body.overflow-hidden .mg-asset-search-block {
    align-items: center !important;
  }

  body.overflow-hidden .mg-gis-toolbar .mg-tb-btn,
  body.overflow-hidden .mg-gis-toolbar-group--compact .mg-tb-btn {
    box-sizing: border-box;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    min-height: 64px !important;
    height: 64px !important;
    padding: 2px 1px !important;
    justify-content: center !important;
  }

  body.overflow-hidden .mg-gis-toolbar .mg-tb-icon,
  body.overflow-hidden .mg-tb-btn--project-logo .mg-tb-icon {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    min-height: 38px !important;
    font-size: 22px !important;
  }

  body.overflow-hidden .mg-gis-toolbar .mg-tb-label,
  body.overflow-hidden .mg-gis-toolbar-group--compact .mg-tb-label {
    font-size: 10px !important;
    line-height: 1.1 !important;
    max-width: 50px !important;
  }

  body.overflow-hidden .mg-gis-toolbar-sep {
    align-self: center !important;
    height: 40px !important;
    margin: 0 1px !important;
  }

  body.overflow-hidden .mg-toolbar-coords {
    font-size: clamp(10px, 1.6vh, 12px) !important;
    padding: 3px 6px !important;
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    flex-shrink: 0 !important;
  }

  body.overflow-hidden .mg-toolbar-fixed-start {
    flex-shrink: 0 !important;
  }

  body.overflow-hidden .mg-center-column > main {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
  }

  body.overflow-hidden #map,
  body.overflow-hidden #threeDContainer {
    height: 100% !important;
    min-height: 0 !important;
  }

  body.overflow-hidden .bottom-bar {
    flex: 0 0 auto;
    min-height: 0;
    max-height: clamp(42px, 7.5vh, 52px);
    padding: 4px 10px;
  }

  body.overflow-hidden .mg-footer-inner {
    min-height: 0;
  }

  body.overflow-hidden .mg-header-user-name {
    font-size: 0.78rem;
    line-height: 1.2;
  }

  body.overflow-hidden .mg-header-user-ip {
    font-size: 0.68rem;
  }

  body.overflow-hidden .mg-gis-project-badge {
    font-size: 0.78rem;
    padding: 3px 8px;
  }
}

html.mg-device-desktop body.overflow-hidden {
  height: 100dvh;
  max-height: 100dvh;
}

html.mg-device-desktop body.overflow-hidden > .mg-app-shell {
  flex: 1 1 0;
  min-height: 0;
  height: 0;
}

html.mg-device-desktop body.overflow-hidden .mg-gis-toolbar {
  min-height: clamp(56px, 11vh, 72px) !important;
}

@media (min-width: 901px) and (max-height: 820px) {
  body.overflow-hidden > header.header {
    max-height: 40px;
  }

  body.overflow-hidden .mg-toolbar-band {
    min-height: 68px;
    max-height: none;
  }

  body.overflow-hidden .mg-gis-toolbar {
    min-height: 52px !important;
  }

  body.overflow-hidden .mg-tb-icon {
    width: 30px !important;
    height: 30px !important;
    font-size: 18px !important;
  }

  body.overflow-hidden .bottom-bar {
    max-height: 44px;
    padding: 3px 8px;
  }
}

@media (min-width: 901px) and (max-height: 700px) {
  body.overflow-hidden .mg-toolbar-band {
    min-height: 56px;
    max-height: none;
  }

  body.overflow-hidden .mg-tb-label {
    display: none;
  }

  body.overflow-hidden .mg-gis-toolbar .mg-tb-btn,
  body.overflow-hidden .mg-gis-toolbar-group--compact .mg-tb-btn {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 48px !important;
    height: 48px !important;
  }

  body.overflow-hidden .mg-gis-toolbar .mg-tb-icon,
  body.overflow-hidden .mg-tb-btn--project-logo .mg-tb-icon {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    font-size: 18px !important;
  }
}

/* טלפון / טאבלט — גלילת סיידבר, סרגל כלים ומפה (גם ברוחב ≤900px) */
html.mg-device-tablet body.overflow-hidden,
html.mg-device-mobile body.overflow-hidden {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

html.mg-device-tablet body.overflow-hidden > .mg-app-shell,
html.mg-device-mobile body.overflow-hidden > .mg-app-shell {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

html.mg-device-tablet body.overflow-hidden .sidebar,
html.mg-device-mobile body.overflow-hidden .sidebar,
html.mg-device-tablet body.overflow-hidden .sidebar-right,
html.mg-device-mobile body.overflow-hidden .sidebar-right {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(42vh, 360px);
  overflow: hidden;
  flex-shrink: 0;
}

html.mg-device-tablet body.overflow-hidden .sidebar #left-content,
html.mg-device-mobile body.overflow-hidden .sidebar #left-content,
html.mg-device-tablet body.overflow-hidden .sidebar-right > div:not(:first-child),
html.mg-device-mobile body.overflow-hidden .sidebar-right > div:not(:first-child) {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
}

html.mg-device-tablet body.overflow-hidden .mg-center-column,
html.mg-device-mobile body.overflow-hidden .mg-center-column {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html.mg-device-tablet body.overflow-hidden .mg-center-column > main,
html.mg-device-mobile body.overflow-hidden .mg-center-column > main {
  flex: 1 1 0;
  min-height: 180px;
  overflow: hidden;
}

html.mg-device-tablet body.overflow-hidden #map,
html.mg-device-mobile body.overflow-hidden #map,
html.mg-device-tablet body.overflow-hidden #threeDContainer,
html.mg-device-mobile body.overflow-hidden #threeDContainer {
  height: 100% !important;
  min-height: 180px !important;
}

html.mg-device-tablet body.overflow-hidden .mg-toolbar-band,
html.mg-device-mobile body.overflow-hidden .mg-toolbar-band {
  flex-shrink: 0;
  max-height: 38vh;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

html.mg-device-tablet body.overflow-hidden .mg-gis-toolbar,
html.mg-device-mobile body.overflow-hidden .mg-gis-toolbar {
  width: max-content;
  min-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  body.overflow-hidden {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.overflow-hidden > .mg-app-shell {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body.overflow-hidden .sidebar,
  body.overflow-hidden .sidebar-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: min(42vh, 360px);
    overflow: hidden;
    flex-shrink: 0;
  }

  body.overflow-hidden .sidebar #left-content,
  body.overflow-hidden .sidebar-right > div:not(:first-child) {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
  }

  body.overflow-hidden .mg-center-column {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.overflow-hidden .mg-center-column > main {
    flex: 1 1 0;
    min-height: 180px;
    overflow: hidden;
  }

  body.overflow-hidden #map,
  body.overflow-hidden #threeDContainer {
    height: 100% !important;
    min-height: 180px !important;
  }

  body.overflow-hidden .mg-toolbar-band {
    flex-shrink: 0;
    max-height: 38vh;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
}

html.mg-device-tablet .mg-app-shell,
html.mg-device-mobile .mg-app-shell {
  flex-direction: column !important;
}

html.mg-device-tablet .mg-center-column,
html.mg-device-mobile .mg-center-column {
  min-height: 45vh;
  flex: 1 1 auto;
}

html.mg-device-tablet .sidebar,
html.mg-device-mobile .sidebar,
html.mg-device-tablet .sidebar-right,
html.mg-device-mobile .sidebar-right {
  width: 100% !important;
  max-width: 100% !important;
  max-height: 36vh;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid var(--mg-border, #454545);
  flex-shrink: 0;
}

html.mg-device-tablet .mg-toolbar-band .header-actions-group,
html.mg-device-mobile .mg-toolbar-band .header-actions-group {
  flex-wrap: wrap;
  max-height: 32vh;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.mg-device-tablet .header,
html.mg-device-mobile .header {
  grid-template-columns: 1fr !important;
  gap: 6px;
  padding: 6px 8px;
}

html.mg-device-mobile .mg-header-left-corner {
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

html.mg-device-mobile .mg-toolbar-band .mg-tb-label {
  display: none;
}

html.mg-device-mobile .bottom-bar {
  flex-wrap: wrap;
  gap: 6px;
  font-size: 10px;
}

/* —— מערכת תיאומים —— */
.coordination-app header {
  flex-wrap: wrap;
  gap: 8px;
}

.coordination-app .header-start {
  flex: 1 1 100%;
  flex-wrap: wrap;
}

.coordination-app .proj-select-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.coordination-app .proj-select-wrap select {
  min-width: 0;
  width: min(100%, 280px);
  max-width: 100%;
}

.coordination-app .toolbar {
  flex: 1 1 100%;
  justify-content: flex-start;
}

.coordination-app .coord-device-host {
  margin-inline-start: auto;
}

html.mg-device-tablet .coordination-app .split-main,
html.mg-device-mobile .coordination-app .split-main {
  flex-direction: column;
}

html.mg-device-tablet .coordination-app .panel-records,
html.mg-device-mobile .coordination-app .panel-records {
  border-left: none;
  border-bottom: 1px solid #e2e8f0;
  max-height: 45vh;
  flex: 0 0 auto;
  min-height: 200px;
}

html.mg-device-tablet .coordination-app .panel-map,
html.mg-device-mobile .coordination-app .panel-map {
  flex: 1 1 auto;
  min-height: 45vh;
}

html.mg-device-tablet .coordination-app .toolbar button,
html.mg-device-tablet .coordination-app .toolbar .btn-link {
  flex: 1 1 auto;
  min-width: calc(50% - 4px);
}

html.mg-device-mobile .coordination-app .panel-records {
  max-height: 40vh;
}

html.mg-device-mobile .coordination-app .toolbar button,
html.mg-device-mobile .coordination-app .toolbar .btn-link {
  width: 100%;
  min-width: 0;
}

@media (max-width: 900px) {
  .coordination-app .split-main {
    flex-direction: column;
  }

  .coordination-app .panel-records {
    border-left: none;
    border-bottom: 1px solid #e2e8f0;
    max-height: 45vh;
    flex: 0 0 auto;
    min-height: 200px;
  }

  .coordination-app .panel-map {
    flex: 1 1 auto;
    min-height: 45vh;
  }
}

/* דפי דשבורד / חשבונות — גלילה אנכית + כפתורי מעלה/מטה */
.mg-scroll-page {
  height: 100vh;
  overflow: hidden;
}

.mg-scroll-page .wrap.mg-scroll-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 12px;
  width: 100%;
  box-sizing: border-box;
}

.mg-scroll-page .mg-scroll-head {
  flex-shrink: 0;
  margin-bottom: 12px;
  padding-bottom: 14px;
}

.mg-scroll-page .mg-scroll-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #38bdf8 rgba(15, 23, 42, 0.85);
  padding-inline-end: 4px;
  padding-bottom: 28px;
}

.mg-scroll-page .mg-scroll-body::-webkit-scrollbar {
  width: 10px;
}

.mg-scroll-page .mg-scroll-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
}

.mg-scroll-page .mg-scroll-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #38bdf8, #2563eb);
  border-radius: 8px;
  border: 2px solid rgba(15, 23, 42, 0.5);
}

.mg-scroll-nav {
  position: fixed;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.mg-scroll-nav-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.92);
  color: #e2e8f0;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: background 0.15s, transform 0.12s;
}

.mg-scroll-nav-btn:hover {
  background: #2563eb;
  border-color: #60a5fa;
  transform: scale(1.05);
}

.mg-scroll-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

@media (max-width: 640px) {
  .mg-scroll-nav {
    inset-inline-start: 8px;
  }

  .mg-scroll-nav-btn {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
}
